Commit Graph

42 Commits

Author SHA1 Message Date
Tomás Pozo
adbd3c3d22 docs: migrate Edge Functions guides to @supabase/server (COM-269) (#46656)
## What

Migrates the Edge Functions **documentation** from the legacy
`Deno.serve` + manual `createClient` pattern to the
[`@supabase/server`](https://github.com/supabase/server) `withSupabase`
wrapper. This is the part of
[COM-269](https://linear.app/supabase/issue/COM-269) that AI coding
assistants index, so it's split out to ship first; the standalone
`examples/` functions follow in a second PR.

## Canonical pattern

```ts
import { withSupabase } from 'npm:@supabase/server@1'

export default {
  fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
    const { data } = await ctx.supabase.from('countries').select('*')
    return Response.json({ data })
  }),
}
```

- `export default { fetch }` object shape (not `Deno.serve`, not a bare
default export), versioned `npm:@supabase/server@1`.
- `auth` mode picks the caller: `user` → `ctx.supabase` (RLS);
`secret`/`publishable`/`none` → set `verify_jwt = false`, `secret` uses
`ctx.supabaseAdmin`.
- `Response.json(...)` over `new Response(JSON.stringify(...))`.

## Changes

- **AI prompt** (`examples/prompts/edge-functions.md`) — rewritten to
lead with `withSupabase` as the default; `auth`-mode table;
`@supabase/server@1`. Highest AI-indexing impact.
- **connect-to-postgres** — "Using supabase-js" now uses `ctx.supabase`
(+ its CodeSample deps `postgres-on-the-edge`, `drizzle`).
- **Example pages** — semantic-search, push-notifications,
amazon-bedrock, cloudflare-turnstile, og-image, send-emails,
slack-bot-mention, auth-send-email-hook.
- **Guides** — ai-models, background-tasks, routing (+ `restful-tasks`
dep), kysely-postgres, sentry-monitoring, upstash-redis, elevenlabs ×2,
websockets, cors (reframed: CORS is automatic with `withSupabase`).

## Notable fixes

- **websockets**: the JWT-auth examples had a latent bug — handler
wasn't `async` and called `getClaims()` without the extracted token. Now
`await supabase.auth.getUser(jwt)`. (`withSupabase` can't authenticate
WebSocket clients since they can't send headers — noted in the page.)
- **restful-tasks**: fixed a broken `npm:supabase-js` import →
`npm:@supabase/supabase-js`.

## Follow-ups (not in this PR)

- The ~42 standalone `examples/` edge functions → second PR.
- A dedicated `withSupabase` intro page (today it's only documented
inside the auth-framed "Securing Edge Functions" page).
- `.claude/skills/supabase-server/SKILL.md` is stale (`allow:` vs
`auth:`).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Updated Edge Function examples to the modern withSupabase + exported
fetch handler pattern across guides and examples.
* Standardized JSON response/error handling (uses built-in JSON helpers)
and preserved streaming/SSE behaviors where applicable.
* Clarified auth modes, context clients (user vs admin), and automatic
CORS handling; removed manual preflight boilerplate.
* Updated local serve/deploy instructions to include --no-verify-jwt for
relevant examples.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-08 12:32:15 -05:00
Tomás Pozo
e3be344f5c fix(examples): read new API keys directly from parsed SUPABASE_SECRET_KEYS (#46604)
## Problem

Edge Function examples that use the new publishable/secret API keys read
them with a double lookup:

```ts
const SUPABASE_SECRET_KEYS = JSON.parse(Deno.env.get('SUPABASE_SECRET_KEYS')!)
const secretKey = Deno.env.get(SUPABASE_SECRET_KEYS['default']) //  returns undefined
```

`SUPABASE_SECRET_KEYS` / `SUPABASE_PUBLISHABLE_KEYS` are a JSON object
that maps a key name to the **actual key value** (e.g.
`{"default":"sb_secret_..."}`), confirmed by:
- the self-hosted injection in `docker/docker-compose.yml`
(`SUPABASE_SECRET_KEYS: "{\"default\":\"${SUPABASE_SECRET_KEY:-}\"}"`)
- the `@supabase/server` SDK README

So `SUPABASE_SECRET_KEYS['default']` is already the key. Wrapping it in
another `Deno.env.get(...)` looks up an env var named `sb_secret_...`,
which doesn't exist, so the value is `undefined` and the examples fail
at runtime.

## Fix

Unwrap the outer `Deno.env.get(...)` so the key is read directly:

```ts
const SUPABASE_SECRET_KEYS = JSON.parse(Deno.env.get('SUPABASE_SECRET_KEYS')!)
const secretKey = SUPABASE_SECRET_KEYS['default'] // 
```

Applied across 23 files (example functions, the
`examples/prompts/edge-functions.md` codegen guidance, and two docs
guides). The correct `JSON.parse(Deno.env.get('SUPABASE_SECRET_KEYS')!)`
declaration line is untouched. The generated `apps/docs/examples/` copy
regenerates from `examples/` at build time.

## Notes

- Docs context:
[#46600](https://github.com/supabase/supabase/pull/46600), which
documents the same key model.
- Follow-up (not in this PR): a few examples send the secret key on the
`Authorization: Bearer` header, which the new keys reject. Worth a
separate audit.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Clarified examples and guides for correctly reading parsed Supabase
secret and publishable key maps.

* **Examples**
* Standardized credential usage across Edge Functions and samples so
Supabase clients consistently receive keys from the parsed key maps
rather than indirect lookups.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Chris Chinchilla <chris.ward@supabase.io>
2026-06-03 11:05:20 -05:00
Rodrigo Mansueli
894cb531d1 feat(docs): add resumable WebSockets + Edge Functions troubleshooting guides (#46178)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Docs update (new guides + follow-up documentation fix from review
feedback).

## What is the current behavior?

There was no consolidated docs example for resumable WebSockets with
Edge Functions, and no dedicated troubleshooting guide for worker
timeouts / WebSocket drops.

## What is the new behavior?

- Adds a resumable WebSockets guide for Edge Functions, including:
  - session persistence
  - event replay
  - idempotency pattern and schema examples
  - client/server example flow
- Adds an Edge Functions troubleshooting guide for worker timeouts and
WebSocket drops.
- Updates docs navigation to surface the new guides.
- Follow-up fix from review feedback: the browser client example now
stores `sessionId` and `lastEventId` in `sessionStorage` (instead of
`localStorage`).

## Additional context

- Branch has been updated with latest `origin/master`.
- This PR remains documentation-focused; no production runtime code
changes were introduced.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added a guide on resumable WebSockets covering session persistence,
event replay, idempotency patterns, SQL schema examples, and
client/server usage.
* Added a troubleshooting guide on Edge Functions worker timeouts and
WebSocket drops with scenarios, symptoms, and practical workarounds.
* Enhanced WebSocket docs with a production note on worker lifecycle and
keeping runtime promises open to avoid premature shutdown.
  * Navigation updated to surface the new guides.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46178?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Lakshan Perera <lakshan@supabase.io>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-05-27 18:34:23 +00:00
Lakshan Perera
4363dbb975 Some trivial fixes to Edge Function guides (#46092)
Was going through user feedback and fixed some of the minor issues with
the guides.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Added guidance on handling CORS when invoking Edge Functions from the
browser (quickstart and dashboard)
* Updated Deno configuration guidance to reference a top-level deno.json
and adjusted recommended project structure
* Improved internal cross-references for templates and shared
documentation links in functions guides

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46092?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Jeremias Menichelli <jmenichelli@gmail.com>
2026-05-20 05:53:47 +10:00
Chris Chinchilla
d8bd6b047c docs: Examples Key changes (#45170)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Updated examples and guides to use Supabase publishable (client) keys
instead of anon keys for client-side usage across frameworks and
platforms.
* Renamed environment variable examples and .env templates to reflect
publishable key naming.
* Adjusted sample requests and client-init examples to send/use the
publishable key via the apikey header where applicable.
* Updated references from service_role to secret for server-side
credential guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: fadymak <fady@fadymak.com>
2026-05-04 12:58:16 +02:00
Chris Chinchilla
b6dba956ef docs: Functions Key changes (#45224)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Replaced legacy "Anon"/"Service Role" key terminology with
"Publishable Keys" and "Secret Keys" across Edge Functions guides
* Updated authentication examples and request headers (client-side vs
server-side) to reflect publishable/secret key usage
* Standardized environment-variable examples to use parsed secret-key
maps with a selectable default
* Removed guidance for bypassing JWT verification via the deprecated CLI
flag
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Kalleby Santos <kalleby_santos@hotmail.com>
2026-04-29 11:12:54 +00:00
Ivan Vasilov
9fa96977be chore: Minor prettier fixes (#43849)
This PR fixes some prettier issues:
- Bump and unify all prettier versions to 3.7.3 across teh whole repo
- Bump the SQL prettier plugin
- When running `test:prettier`, check `mdx` files also
- Run the new prettier format on all files

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-17 11:17:42 +01:00
Katerina Skroumpelou
a0b946f1a2 docs: update cors documentation to include new method (#42644)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Updated Edge Functions CORS header guides with version-specific
approaches for SDK v2.95.0+ and earlier versions.
* Revised code examples across multiple Edge Functions to reflect
current CORS header implementation patterns.
* Enhanced troubleshooting documentation with updated preflight handling
guidance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-10 18:32:32 +02:00
Katerina Skroumpelou
c730dc37fd Revert "docs: update cors documentation to include new method" (#42524)
Reverts supabase/supabase#42506

`esm.sh` does not work, so we will revert this version for now.
2026-02-05 21:03:33 +01:00
Katerina Skroumpelou
525c0d7e13 docs: update cors documentation to include new method (#42506)
v2.95.0 of the supabase-js sdk has been released, which contains
https://github.com/supabase/supabase-js/pull/2071

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Updated guides and examples to recommend using CORS headers from the
Supabase JS SDK (v2.95.0+) instead of manually defining headers.
* Examples now show the SDK-based approach and include a clear fallback
path for older SDK versions that require hardcoded headers.
* Added notes that SDK header updates will be reflected automatically in
edge functions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-05 17:56:34 +02:00
Cemal Kılıç
0e549e9ee5 chore: strip prefix in hookSecret, update docs and related examples (#39799)
Updated hookSecret to remove 'v1,whsec_' prefix to have the consistency
in the docs

---------

Co-authored-by: Timothy Lim <tim.lim@supabase.io>
2026-02-03 21:03:19 +00:00
Danny White
19cf4bb4bf feat(studio): consolidate settings phase 2 (#37612)
* new slugs

* remove symlinks

* rabbit
2026-01-26 15:41:05 +08:00
Andrew Agostini
67faf37ca7 docs: Fix broken URLS batch 4 (#40548)
docs: Fix broken links in various guides and blog posts
2025-11-28 17:34:31 +08:00
Andrew Agostini
a6a598f824 docs: Fix broken urls (#40457)
* docs: update link to Vecs Python source code in developers guide

* docs: update README to remove outdated GDScript links. These repos have been deleted

* docs: update links in CONTRIBUTING.md for consistency and accuracy

* docs: update Twilio verification service link

* docs: update Mixpeek Python Client link in video search guide, remove link to missing code example

* docs: update GIN index link to point to PostgreSQL 16 documentation ('current' symantic no longer exists)

* docs: update Cloudflare Turnstile links to avoid 302 redirect

* docs: update LlamaIndex SupabaseVectorStore link to the correct documentation

* docs: update link to related issue for error message translation in auth-ui guide (to avoid 302 redirect)

* docs: update link from Next.js middleware to Next.js Proxy in auth-helpers guide to follow Next.js's new naming convention

* Update DEVELOPERS.md

* Update CONTRIBUTING.md

Direct to correct URL

* Update hybrid-search.mdx

Fix URL

* docs: renam Next.js middleware to proxy

* Update DEVELOPERS.md

Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>

---------

Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
2025-11-28 08:58:11 +00:00
Pedro Rodrigues
a1f73e57df docs: add MCP-lite Edge Functions tutorial (#40004)
* Add Pedro Rodrigues to humans.txt

* docs: add MCP-lite Edge Functions tutorial

- Add comprehensive tutorial on building MCP servers with mcp-lite on Supabase Edge Functions
- Add navigation entries in Examples and Third-Party Tools sections
- Based on Fiberplane blog post about mcp-lite and Supabase integration

* docs: remove redundant 'supabase init' step from MCP-lite tutorial

The template from 'npm create mcp-lite@latest' already initializes Supabase, so this step is not needed.

* docs: clarify local development steps for MCP-lite tutorial

- Separate 'supabase start' and 'supabase functions serve' into distinct steps
- Clarify that npm run dev only serves the function, not starts Supabase
- Make it clear these should be run in separate terminals

* style: format MCP-lite tutorial with prettier

* Update apps/docs/content/guides/functions/examples/mcp-server-mcp-lite.mdx

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix rules

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chris Chinchilla <chris.ward@supabase.io>
2025-10-31 12:53:46 +01:00
Tyler
5cfc390a6a docs: Add schema qualified object references throughout the docs (#39904)
* Update vector type

* Update http and postgis

* Missed a spot on Postgis

* convert the gis reference to extensions in postgis guide
2025-10-28 17:42:50 +09:00
Charis
47705a8968 chore: replace all supabase urls with relative urls (#38537)
* fix: rewrite relative URLs when syncing to GitHub discussion

Relative URLs back to supabse.com won't work in GitHub discussions, so
rewrite them back to absolute URLs starting with https://supabase.com

* fix: replace all supabase urls with relative urls

* chore: add linting for relative urls

* chore: bump linter version

* Prettier

---------

Co-authored-by: Chris Chinchilla <chris.ward@supabase.io>
2025-09-09 12:54:33 +00:00
Charis
e2fecc0f5d chore(docs linter): bump version (#36715)
* chore(docs linter): bump version

* style: format
2025-07-03 14:46:29 +00:00
Charis
7cc64d3bd1 docs(edge functions): document that sentry needs to be manually flushed before main function returns (#36537)
docs(edge functions): document that sentry needs to be manually flushed before
main function returns

Resolves #36489
2025-06-19 14:14:29 -04:00
Lakshan Perera
3c390c7891 chore: Use npm specifier instead of jsr for supabase-js imports (#36291)
chore: update examples to use npm specifier instead of jsr
2025-06-09 22:36:48 -04:00
Maxwell Mandela
c31ac2501d Update auth-send-email-hook-react-email-resend.mdx - typo (#36103)
Update auth-send-email-hook-react-email-resend.mdx

Fix a small typo from '...needs to be send' to '...needs to be sent'
2025-06-02 14:37:44 +00:00
Meshack
621ca9a43a Update link to database webhooks settings in edge functions example for push notifications (#33120)
Update link to webhooks settings in edge functions example for push notifications

After the recent addition of integrations and database webhooks settings being moved to the integrations page, the link to database webhooks settings in the edge functions example for push notifications led to a 404.
2025-03-27 16:47:28 +00:00
Thor 雷神 Schaeff
5411a55d16 chore: fix small typos. (#34062) 2025-03-07 17:11:46 +00:00
Thor 雷神 Schaeff
99f1d1fc16 Thor/add elevenlabs streaming example n docs (#33989)
* feat: add TTS & STT docs.

* feat: add examples.

* fix: docs.

* code review nits.

* chore: format.

* Fix mdx-lint errors.

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2025-03-07 09:08:56 +01:00
Charis
a820c56ed0 chore: docs linting (#33574) 2025-02-21 14:13:00 -05:00
Rodrigo Mansueli
aea6ad069b chore: update stripe webhook example (#33774)
* Chore: Update stripe-webhooks.mdx

* Update index.ts
2025-02-21 15:30:13 -03:00
Charis
2d55512553 chore: activate spelling and admonitions lints for docs (#33292) 2025-02-04 13:18:31 -05:00
Charis
4cecae1e09 ci(docs): linter bump version + expand scope (#30860) 2024-12-04 20:37:49 +00:00
Marc Köhler
5f29b9200e fix(docs/auth): typo (#30786) 2024-12-03 00:29:31 +00:00
Lara Raoof
a579396dcd Update actions/checkout to use v4 (node 20) (#30502) 2024-11-20 08:19:12 +00:00
Lakshan Perera
ef6353e84c Edge Function example on image manipulation (#29658)
* chore: add magick-wasm example functions

* chore: add image manipulation guide
2024-10-03 17:47:55 +08:00
Thor 雷神 Schaeff
2ae41b620e Add Auth Hook Resend Example. (#28805) 2024-08-23 21:31:35 +08:00
hallidayo
0eec3f1de6 docs: resend edge functions key (#28074)
added warning for keys management
2024-07-19 17:17:55 +00:00
Thor 雷神 Schaeff
0dbb5e5225 docs: update deno deps to jsr. (#27766)
docs: update deno desp to jsr.
2024-07-03 18:06:55 +08:00
Kamil Ogórek
7940e50d93 Sentry docs updates (#27092)
* docs: Update Sentry integration docs to work with SDK v8

* docs: Update Edge Functions monitoring with Sentry with note about scopes

* docs: Reportdog stylistic updates

* misc: Fix prettier errors
2024-06-07 14:49:47 +00:00
Tyler
dcc2d49445 docs: Add FCM video at the end of FCM section of push notifications guide (#27018)
* docs: Add FCM video at the end of FCM section of push notification guide

* run prettier
2024-06-05 12:23:24 +09:00
Thor 雷神 Schaeff
1a571a2368 docs: edgy bedrock. (#26909)
* docs: edgy bedrock.

* fix: nav.

* Apply suggestions from code review

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2024-06-01 22:28:39 +08:00
Thor 雷神 Schaeff
2a4c525cd2 docs: ai in ef docs guide (#22788)
* wip: add semantic search example

* chore: complete ef ai guide.

* chore: update ai docs.

---------

Co-authored-by: Lakshan Perera <lakshan@laktek.com>
2024-04-16 21:36:19 +08:00
albadedan
deb272ff1b Update cloudflare-turnstile.mdx (#22404)
Incorrect secret name in documentation breaks implementation.
2024-04-02 19:48:11 +00:00
Charis
14ca7b6ed9 docs: add sentry integration docs (#21439)
* docs: add sentry integration docs

* feat: add sentry edge functions monitoring guide.

* feat: add sentry functions example.

* fix: navbar.

* chore: nits.

* chore: add to functions example list.

* fix: formatting.

* chore: add nextjs example.

* fix: rename sentry guide

* remove configuration options

* Apply suggestions from code review

Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>

---------

Co-authored-by: thorwebdev <thor@supabase.io>
Co-authored-by: Thor 雷神 Schaeff <5748289+thorwebdev@users.noreply.github.com>
Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
2024-03-06 14:50:03 +00:00
Ronan O'Driscoll
15887ee164 Minor correction to FCM Push Notifications Guide (#21370)
* Minor correction to FCM Push Notifications Guide

Hi,
Just some minor edits to the FCM guide I wanted to share.
Thanks,
Ronan O'Driscoll

* Apply suggestions from code review

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2024-02-20 23:41:36 +00:00
Charis
42723d8232 refactor: move ai, realtime, functions, remaining auth docs to content directory (#21259) 2024-02-14 17:39:05 +00:00