Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Laravel + NextJS monorepo starter kit
Laranext Monorepo is a free boilerplate starter kit that pairs a Laravel backend with a Next.js frontend in a single Lerna-managed monorepo, built on the official Laravel Breeze scaffolding with NextJS.
Laranext Monorepo is a starter kit that combines a Laravel backend running on PHP 8 with a Next.js frontend built with React, all housed in one repository. The project uses Lerna and npm workspaces to manage two separate packages: the Laravel application inside the backend folder and the Next.js application inside the frontend folder. It is based on the Laravel Breeze scaffolding with NextJS, which means authentication is already wired up through a custom useAuth React hook. The hook abstracts login, logout, and user retrieval, and accepts middleware configurations such as auth to protect pages. The repository is authored by isaacdarcilla and is designed to save developers from manually connecting a Laravel API to a React frontend.
The most distinctive aspects of this starter are its monorepo organization and its authentication setup.
npm run dev -w @mono/backend or npm run dev -w @mono/frontend directly from the root directory.useAuth hook — A custom React hook exposes the current user and a logout function; it takes a middleware option such as auth to control page access, and you must use optional chaining like user?.name because of Next.js server-side rendering.php artisan migrate --seed, which creates the necessary tables and populates them with sample data.php artisan serve or via npm workspaces, and the frontend with npm run dev, either in separate terminals or with workspace flags.This starter is aimed at full-stack developers who want a Laravel API backend and a Next.js frontend in a single codebase without spending time on the initial wiring. It is also a good fit for teams that already use Lerna for monorepo management, and for Laravel developers who want to adopt React on the frontend instead of Blade views.
With this starter you can quickly launch a full-stack application and customize the workspace to fit your workflow.
-w flag, as illustrated with npm install husky -D -w @mono/frontend.useAuth hook with the auth middleware, and can access named routes from Laravel through Ziggy.The workflow starts by cloning the repository and installing Node dependencies with npm install. After that, you install Composer packages inside the backend directory and run php artisan migrate --seed to prepare the database. You must set APP_URL to http://localhost:8000 and FRONTEND_URL to http://localhost:3000 in your environment files. Then you start the Laravel server with php artisan serve (or via the workspace command) and the Next.js development server with npm run dev. The final application runs at http://localhost:3000.
