Laravel Breeze 认证启动套件的 Next.js 前端实现,认证样板代码已预先写好
next-lara-frontend — Next.js 启动器模板
作者 ThawZin999
基于 Laravel Breeze 的 Next.js 前端启动器,配合 Laravel Sanctum 提供认证样板,用于将 Next.js 前端与 Laravel REST API 后端配对。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
认证由 Laravel Sanctum 提供支持,用于配对 Laravel REST API 后端
提供自定义 useAuth React hook,将认证逻辑从页面中抽离并获取当前用户
可通过 Ziggy 在 React 应用中引用 Laravel 的命名路由 URL
采用 MIT 许可,允许免费使用、修改、商用和分发该版本代码
模板详细介绍
该仓库是 Laravel Breeze 认证启动套件的 Next.js 前端实现,认证样板代码已预先写好,由 Laravel Sanctum 提供支持,便于把 Next.js 前端与 Laravel 后端配对使用。
使用方式上,后端需先创建 Laravel 应用并安装 Breeze 的 API 脚手架(php artisan breeze:install api),执行数据库迁移,并将 APP_URL 与 FRONTEND_URL 分别设为 http://localhost:8000 和 http://localhost:3000。前端克隆仓库后安装依赖,把 .env.example 复制为 .env.local 并填入 NEXT_PUBLIC_BACKEND_URL,再运行 npm run dev,应用默认在 http://localhost:3000 可用。README 建议本地开发时前后端都使用 localhost,以避免 CORS 的同源问题。
代码层面包含自定义的 useAuth React hook,用于把认证逻辑从页面中抽离,并可获取当前已认证用户;访问用户对象属性时需使用可选链(如 user?.name),以应对 Next.js 的初始服务端渲染。此外可借助 Ziggy 在 React 应用中引用 Laravel 的命名路由 URL。
许可方面,仓库采用 MIT 许可,允许免费使用、修改、商用和分发该版本代码,分发时需保留版权声明与完整 MIT 许可声明;演示图片、字体、图标等第三方素材以及域名、托管、数据库等外部服务需另行核对许可或费用。
适合你的项目吗?
适用场景
- 为 Laravel 后端搭建配套的 Next.js 认证前端
- 在已有 Laravel 应用中接入 Breeze API 脚手架并配对独立前端
- 以 useAuth hook 为基础组织页面级认证与用户信息读取
适合人群
- 使用 Laravel 作为后端、希望前端采用 Next.js 的项目
- 需要现成认证样板而非从零编写登录注册流程的开发者
- 接受前后端分离、通过 REST API 与 Sanctum 通信的团队
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
后端需创建 Laravel 应用并执行 composer require laravel/breeze --dev 与 php artisan breeze:install api,然后运行 php artisan migrate
- 2
后端环境变量 APP_URL 与 FRONTEND_URL 分别设为 http://localhost:8000 和 http://localhost:3000,并用 php artisan serve 启动
- 3
前端克隆仓库后安装依赖,将 .env.example 复制为 .env.local 并设置 NEXT_PUBLIC_BACKEND_URL,再运行 npm run dev
- 4
本地开发建议前后端均使用 localhost,以避免 CORS 同源问题
- 5
访问用户对象属性时使用可选链(如 user?.name),以应对 Next.js 的初始服务端渲染
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 使用该前端模板前,必须自行搭建一个兼容的 Laravel 后端:在全新的 Laravel 应用中安装 Laravel Breeze 并执行其 API 脚手架,否则前端无法独立运行。
- 后端需配置 APP_URL 与 FRONTEND_URL 环境变量,分别指向后端与前端地址,否则前后端通信与认证会失败。
- 前端必须将 .env.example 复制为 .env.local 并填入后端 URL(NEXT_PUBLIC_BACKEND_URL),否则无法连接后端。
- 本地开发时建议前后端均使用 localhost,以避免 CORS 同源问题;使用其他域名可能触发跨域限制。
- 访问用户对象属性时必须使用可选链(如 user?.name),否则会因 Next.js 初始服务端渲染而报错。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
First, create a Next.js compatible Laravel backend by installing Laravel Breeze into a [fresh Laravel application](https://laravel.com/docs/installation) and installing Breeze's API scaffolding:
README 原文
Next, ensure that your application's `APP_URL` and `FRONTEND_URL` environment variables are set to `http://localhost:8000` and `http://localhost:3000`, respectively.
README 原文
Then, copy the `.env.example` file to `.env.local` and supply the URL of your backend:
README 原文
> Note: Currently, we recommend using `localhost` during local development of your backend and frontend to avoid CORS "Same-Origin" issues.
README 原文
https://github.com/ThawZin999/next-lara-frontend/blob/main/LICENSE.mdhttps://github.com/ThawZin999/next-lara-frontend/blob/main/README.md> Note: You will need to use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) (`user?.name` instead of `user.name`) when accessing properties on the user object to account for Next.js's initial server-side render.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-13。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料一般 · 73 / 100
- 技术栈
- Next.js · Laravel · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2024-02-16
- 截图检查日期
- 2026-10-13
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: [email protected] · 2026-10-13
查看当时使用的来源资料
SHA-256: 2afcc757fce46540de1a45e889d2ceced580183a0061e0fe63ef83c2746695cd
2026-10-13T10:06:12.385Z
来源文件 / 仓库# Laravel Breeze - Next.js Edition ▲
## Introduction
This repository is an implementation of the [Laravel Breeze](https://laravel.com/docs/starter-kits) application / authentication starter kit frontend in [Next.js](https://nextjs.org). All of the authentication boilerplate is already written for you - powered by [Laravel Sanctum](https://laravel.com/docs/sanctum), allowing you to quickly begin pairing your beautiful Next.js frontend with a powerful Laravel backend.
## Official Documentation
### Installation
First, create a Next.js compatible Laravel backend by installing Laravel Breeze into a [fresh Laravel application](https://laravel.com/docs/installation) and installing Breeze's API scaffolding:
```bash
# Create the Laravel application...
laravel new next-backend
cd next-backend
# Install Breeze and dependencies...
composer require laravel/breeze --dev
php artisan breeze:install api
# Run database migrations...
php artisan migrate
```
Next, ensure that your application's `APP_URL` and `FRONTEND_URL` environment variables are set to `http://localhost:8000` and `http://localhost:3000`, respectively.
After defining the appropriate environment variables, you may serve the Laravel application using the `serve` Artisan command:
```bash
# Serve the application...
php artisan serve
```
Next, clone this repository and install its dependencies with `yarn install` or `npm install`. Then, copy the `.env.example` file to `.env.local` and supply the URL of your backend:
```
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
```
Finally, run the application via `npm run dev`. The application will be available at `http://localhost:3000`:
```
npm run dev
```
> Note: Currently, we recommend using `localhost` during local development of your backend and frontend to avoid CORS "Same-Origin" issues.
### Authentication Hook
This Next.js application contains a custom `useAuth` React hook, designed to abstract all authentication logic away from your pages. In addition, the hook can be used to access the currently authenticated user:
```js
const ExamplePage = () => {
const { logout, user } = useAuth({ middleware: 'auth' })
return (
<>
<p>{user?.name}</p>
<button onClick={logout}>Sign out</button>
</>
)
}
export default ExamplePage
```
> Note: You will need to use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) (`user?.name` instead of `user.name`) when accessing properties on the user object to account for Next.js's initial server-side render.
### Named Routes
For convenience, [Ziggy](https://github.com/tighten/ziggy#spas-or-separate-repos) may be used to reference your Laravel application's named route URLs from your React application.
## Contributing
Thank you for considering contributing to Breeze Next! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
Please review [our security policy](https://github.com/laravel/breeze-next/security/policy) on how to report security vulnerabilities.
## License
Laravel Breeze Next is open-sourced software licensed under the [MIT license](LICENSE.md).
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

ai-website-cloner-template
Clone any website with one command using AI coding agents
Next.js · 启动器

Next.js SaaS Starter
Next.js SaaS Starter 是 Next.js 官方维护的 SaaS 起点模板,定位介于学习资源和可直接部署的脚手架之间。
Next.js · SaaS

Next.js Commerce
Next.js Commerce 是 Vercel 团队维护的电商启动模板,基于 Next.js App Router 构建,采用服务端渲染、React Server Components、Server Actions …
Next.js · 电商

Next-js-Boilerplate
Next-js-Boilerplate 是一个面向 Next.js 16、Tailwind CSS 4 和 TypeScript 的启动器,核心定位是开发者体验优先。
Next.js · 启动器

tailwind-nextjs-starter-blog
tailwind-nextjs-starter-blog 是一个面向个人技术博客的 Next.js 与 Tailwind CSS 启动模板,其 v2 版本基于 App Router 与 React Server Comp…
Next.js · 博客

next-forge
Production-grade Turborepo template for Next.js apps.
Next.js · 启动器
