Server: createSupabaseContext

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.

Parameters

Examples

User auth

const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
if (error) {
  // `toJSON()` yields { source, code, message, hint, docs, details }
  return Response.json(error.toJSON(), { status: error.status })
}
const { data } = await ctx.supabase.rpc('get_my_items')