Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
88%
Published
2 months ago (1.0.0)
supabase-edge-function-helpers
Elegant helpers for Supabase Edge Functions with Deno, including CORS handling and typed Supabase client presets.
Installation
denopm add @huy9k/supabase-edge-function-helpers # or npx jsr add @huy9k/supabase-edge-function-helpers
Usage
CORS Handling
import { corsHeaders, handleCors } from "jsr:@huy9k/supabase-edge-function-helpers"; Deno.serve(async (req) => { // Handle CORS preflight const cors = handleCors(req); if (cors) return cors; // ...your logic... return new Response("Hello", { headers: corsHeaders }); });
Supabase Client Presets
import { clientPresets } from "jsr:@huy9k/supabase-edge-function-helpers"; // Admin client (service role) const admin = clientPresets.admin(); // User client (JWT) const user = clientPresets.user("<jwt>"); // Anonymous client const anon = clientPresets.anon();
API Reference
corsHeaders: Record<string, string>
CORS headers for Supabase Edge Functions. Use in all responses.
handleCors(req: Request): Response | null
Returns a 204 CORS preflight response if req.method === "OPTIONS"
, otherwise null
.
clientPresets
admin(): SupabaseClient
— UsesSUPABASE_URL
andSUPABASE_SERVICE_ROLE_KEY
from env.user(token: string): SupabaseClient
— UsesSUPABASE_URL
,SUPABASE_ANON_KEY
and setsAuthorization: Bearer <token>
.anon(): SupabaseClient
— UsesSUPABASE_URL
andSUPABASE_ANON_KEY
.
Environment Variables
SUPABASE_URL
SUPABASE_SERVICE_ROLE_KEY
SUPABASE_ANON_KEY
These must be set in your Edge Function environment.
Compatibility
- Designed for Supabase Edge Functions and Deno Deploy.
- Requires Deno runtime and access to
Deno.env
. - All imports are version-pinned for JSR compatibility.
License
MIT
Built and signed on
GitHub Actions
Add Package
deno add jsr:@huy9k/supabase-edge-function-helpers
Import symbol
import * as supabase_edge_function_helpers from "@huy9k/supabase-edge-function-helpers";
Import directly with a jsr specifier
import * as supabase_edge_function_helpers from "jsr:@huy9k/supabase-edge-function-helpers";
Add Package
pnpm i jsr:@huy9k/supabase-edge-function-helpers
pnpm dlx jsr add @huy9k/supabase-edge-function-helpers
Import symbol
import * as supabase_edge_function_helpers from "@huy9k/supabase-edge-function-helpers";
Add Package
yarn add jsr:@huy9k/supabase-edge-function-helpers
yarn dlx jsr add @huy9k/supabase-edge-function-helpers
Import symbol
import * as supabase_edge_function_helpers from "@huy9k/supabase-edge-function-helpers";
Add Package
vlt install jsr:@huy9k/supabase-edge-function-helpers
Import symbol
import * as supabase_edge_function_helpers from "@huy9k/supabase-edge-function-helpers";
Add Package
npx jsr add @huy9k/supabase-edge-function-helpers
Import symbol
import * as supabase_edge_function_helpers from "@huy9k/supabase-edge-function-helpers";
Add Package
bunx jsr add @huy9k/supabase-edge-function-helpers
Import symbol
import * as supabase_edge_function_helpers from "@huy9k/supabase-edge-function-helpers";