Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Next.js SSR starter kit for Laravel Sanctum token-based authentication, with server-side auth, CSRF protection, and refresh tokens.

A full-stack Next.js TypeScript template focused on functionality over UI, featuring Zustand, TanStack Query, and ESLint 9 support.
nextjs-ssr-laravel-kit is a free open-source starter kit that gives a Next.js Pages Router frontend server-side authentication against a Laravel Sanctum token-based API, replacing next-auth with a simpler custom flow. The repository ships both the Next.js app and a Laravel backend under the /laravel directory, plus Docker Compose for one-command startup.
nextjs-ssr-laravel-kit is a starter kit that combines a Next.js frontend with a Laravel Sanctum backend to deliver stateless, server-side authentication. It takes a Laravel API as its backend dependency and produces a Next.js application with login, registration, email verification, password reset, and protected pages. It runs on Next.js Pages Router with API Routes and uses Axios for HTTP requests. The project is maintained by CODE-AXION on GitHub.
The Next.js backend acts as a proxy to the Laravel API. Pages that need a logged-in user call withAuth as a getServerSideProps wrapper, which fetches user data from the Laravel user endpoint and applies route checks. Next.js API routes that mutate data use withValidation to verify CSRF tokens. For authenticated API calls, developers use createAxiosInstance which attaches the access-token cookie and refreshes it via axios interceptors when expired; public endpoints can be reached with a plain axios call to the NEXT_BACKEND_URL.
Yes. This starter kit is designed specifically for Laravel Sanctum in token-based (not session) mode. The README says to use the Sanctum package from the repository instead of Laravel Breeze API because Breeze uses sessions.
The application will crash. The README states the key is required and that a random value must be added to .env.local to run the frontend.
Access tokens expire after 1 day and refresh tokens after 7 days by default. The expiration values are set in the Laravel config/sanctum.php file, and the README warns to always specify expiration in seconds.
No. The author tried next-auth but found refresh-token handling and cookie expiration too complex, so this kit implements a custom auth flow with axios interceptors and HttpOnly cookies.
Yes. The repository includes a docker-compose file. Cloning the repo and running docker compose up starts both the Laravel backend and the Next.js frontend, accessible at http://localhost:3000.