I'm building an HR Management System using:

  • Backend: Laravel

  • Frontend: Next.js

  • Authentication(SPA): Laravel Breeze (already set up for backend)

I'm a beginner in Next.js, and I’m a bit stuck on how to properly connect the frontend with my Laravel backend using API authentication (tokens).

Here’s what I need help with:

  1. Best structure and standard practices for using Laravel as an API backend with Next.js as the frontend.

  2. Token-based authentication — how to handle login, logout, and token expiration (using Laravel Sanctum).

  3. Middleware setup — for both backend (protecting routes) and frontend (redirecting unauthorized users).

  4. Clean and secure way to persist authentication state on the Next.js side (cookies, localStorage, etc.).

I’ve already configured Laravel Breeze for authentication, but now that I’m moving to Next.js, I’m not sure how to integrate it properly.

Could someone please guide me on the standard approach or provide a simple example structure for this setup?

0

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.