Creates a SupabaseContext directly from a request.
Use this when you need the context without the full withSupabase wrapper — e.g., inside framework route handlers or custom middleware. Returns a result tuple instead of producing a Response.
Response
The incoming HTTP request.
Optional
Auth modes, environment overrides. The cors option is ignored here.
cors
{ data: SupabaseContext, error: null } on success, { data: null, error: AuthError } on failure.
{ data: SupabaseContext, error: null }
{ data: null, error: AuthError }
const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })if (error) { return Response.json({ message: error.message }, { status: error.status })}const { data } = await ctx.supabase.rpc('get_my_items') Copy
const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })if (error) { return Response.json({ message: error.message }, { status: error.status })}const { data } = await ctx.supabase.rpc('get_my_items')
Creates a SupabaseContext directly from a request.
Use this when you need the context without the full withSupabase wrapper — e.g., inside framework route handlers or custom middleware. Returns a result tuple instead of producing a
Response.