createSupabaseAuthMiddleware
SolvaPay SDK / next/src / createSupabaseAuthMiddleware
Function: createSupabaseAuthMiddleware()
createSupabaseAuthMiddleware(
options): (request) =>Promise<NextResponse<unknown>>
Defined in: packages/next/src/helpers/middleware.ts:236
Creates a Next.js middleware function for Supabase authentication
Convenience function that creates a SupabaseAuthAdapter and wraps it with createAuthMiddleware. Only use this if you're using Supabase - otherwise use createAuthMiddleware with your own adapter.
Uses dynamic import to avoid requiring Supabase as a dependency in @solvapay/next.
Parameters
options
SupabaseAuthMiddlewareOptions = {}
Configuration options
Returns
Next.js middleware function (can be exported as middleware or proxy)
(
request):Promise<NextResponse<unknown>>
Parameters
request
NextRequest
Returns
Promise<NextResponse<unknown>>
Examples
// middleware.ts (at project root)
import { createSupabaseAuthMiddleware } from '@solvapay/next';
export const middleware = createSupabaseAuthMiddleware({
publicRoutes: ['/api/list-plans'],
});
export const config = {
matcher: ['/api/:path*'],
};
// src/proxy.ts (in src/ folder, not project root)
import { createSupabaseAuthMiddleware } from '@solvapay/next';
// Use 'proxy' export for Next.js 16 (no deprecation warning)
export const proxy = createSupabaseAuthMiddleware({
publicRoutes: ['/api/list-plans'],
});
export const config = {
matcher: ['/api/:path*'],
};
File Location Notes:
- Next.js 15: Place
middleware.tsat project root - Next.js 16 without
src/folder: Placemiddleware.tsorproxy.tsat project root - Next.js 16 with
src/folder: Placesrc/proxy.tsorsrc/middleware.ts(insrc/folder, not root)
Note: Next.js 16 renamed "middleware" to "proxy". You can export the return value as either
middleware or proxy - both work, but proxy is recommended to avoid deprecation warnings.