Features
Private Pages and API Routes
Launch Express uses Next Auth v5(AuthJS) to secure private pages and API routes, ensuring that only authenticated users can access certain parts of your application. This guide will walk you through the process of creating and managing private content in your Launch Express project.
Securing Pages
Client-Side Protection
To protect client-side routes, use getCurrentUser()
to check if the user is authenticated. If not, redirect them to the login page using the signIn()
function:
Server-Side Protection
For server-side route protection, use the auth()
function provided by Next Auth:
Securing API Routes
To protect API routes, use the auth()
function in your route handlers:
Was this page helpful?