Migration guide for @frontegg/nextjs@9.1.1
The latest versions of @frontegg/nextjs
now support Next.js 15, introducing additional enhancements and updates. In this release, the getSessionOnEdge
function has been deprecated in favor of the new handleSessionOnEdge
function. This new handler offers better flexibility and control for managing sessions on the edge.
Alternatively, if you have complex session checks that don't require automatic redirection to the login page, you can use the checkSessionOnEdge
function. This method will verify the session without redirecting, allowing you to handle invalid sessions manually.
To migrate, replace instances of getSessionOnEdge
with handleSessionOnEdge
as shown in the example below:
handleSessionOnEdge
in middleware.ts
import { NextRequest } from 'next/server'; import { handleSessionOnEdge } from '@frontegg/nextjs/edge'; export const middleware = async (request: NextRequest) => { const { pathname, searchParams } = request.nextUrl; const headers = request.headers; // shouldByPassMiddleware from getSessionOnEdge was moved under the hood of handleSessionOnEdge // Additional logic if needed return handleSessionOnEdge({ request, pathname, searchParams, headers }); }; export const config = { matcher: '/(.*)', };
hostedLoginBox
replaced by FRONTEGG_HOSTED_LOGIN
hostedLoginBox:true
that was passed under withFronteggApp
in pages directory. Is now required to be passed from the env.file
shouldByPassMiddleware
moved under handleSessionOnEdge
The functionality is designed for the following:
- To protect all application routes.
- Static files and image requests.
Currently it is implemented by default and the below are whitelisted.
The default whitelists:
- _next/static (static files)
- _next/image (image optimization files)
- favicon.icon (favicon file)
- api/frontegg (API frontegg middleware)
- account/[login|logout|saml/callback|...] (Frontegg authentication routes)
The default whitelist can be overriden by passing the options parameter.
NOTE: this will slow down your application due to session checks.