Files
supabase/apps/docs/content/guides/functions/deploy.mdx
Colum Ferry 95cf9a78a7 docs(cli): show config examples in TOML and JSONC (#53449)
## Problem

The CLI reads `supabase/config.jsonc` (and `config.json`) since v3.1.0,
but every docs page still shows `config.toml` only. There's also no page
explaining the formats, how to switch, the `$schema` / `#:schema`
declaration, or editor setup, and no reference pages for the new
`supabase config convert` and `supabase config validate` commands.

Linear: CLI-2871

## Solution

- **Dual-format examples from one source.** A new directive
(`features/directives/ConfigFormats.ts`) picks up any ```` ```toml ````
fence with `name=supabase/config.toml` and renders it as
`supabase/config.toml` / `supabase/config.jsonc` tabs. The JSONC is
generated at build time with `convertCliConfigTomlToJsonc` from
`@supabase/config`, the same converter `supabase config convert` uses,
so authors only write TOML and the JSONC matches what the CLI would
produce (comments included). Inside `<$CodeTabs>` the JSONC is added as
an extra tab.
- **The format choice sticks.** `ConfigCodeTabs` keeps the selected
format in `localStorage`, so choosing JSONC switches every config
example on the page and on later pages.
- **Config reference.** The `usage` examples on
`/guides/local-development/cli/config` use the same tabs (they were
highlighted as Python before), and the intro mentions `config.jsonc`.
The `remotes.<branch_name>` example now uses `[remotes.staging]`, since
`<branch_name>` isn't a valid TOML key.
- **New guide, "Config file formats"**
(`/guides/local-development/cli/config-formats`): which file wins,
minimum CLI version, `convert` and `validate`, schema declaration and
versioning, and editor setup (VS Code trusted domains, Even Better TOML,
Tombi, SchemaStore).
- **CLI reference.** Adds `supabase-config-convert` and
`supabase-config-validate` to the CLI reference nav.
`cli_v1_commands.yaml` is the generated v3.2.0 reference, identical to
the release bot's update in #53463, so the two PRs don't conflict.
- **Content.** About 60 existing config examples across the guides,
including the Branching configuration page, are tagged
`name=supabase/config.toml`. Branching reads `config.json` and
`config.jsonc` as well, and the Branching configuration page now says
so. Non-Supabase TOML (`pyproject.toml`, `bunfig.toml`) and the v2-era
`[inbucket]` before/after snippet stay TOML-only.
- **Format-neutral prose.** Sentences that described the config as
`config.toml` now say "your config file", naming `supabase/config.toml`
and `supabase/config.jsonc` once per page. TOML section syntax in prose
(`max_frequency` under `[auth.email]`) is written as key paths
(`auth.email.max_frequency`), which read the same in both formats.
Headings that named `config.toml` keep their old anchors. Sentences
about what `supabase init` creates still say `config.toml`.
- **Markdown export for agents.**
`internals/generate-guides-markdown.ts` runs the same transform, so the
`.md` pages served to AI agents include the JSONC example after each
TOML one.
- A test converts every tagged example under `content/`, so a broken
TOML example fails tests instead of the build.

New dependencies for `apps/docs`: `@supabase/config` (^1.8.0) and
`effect` (the same `effect` version Studio pins).

`config convert` and `config validate` ship in CLI v3.2.0, which is now
stable.

## Review instructions

1. Open `/docs/guides/local-development/seeding-your-database` on the
preview. Switch an example to `supabase/config.jsonc` and check the
other examples on the page switch too.
2. Open `/docs/guides/local-development/cli/config` and check the usage
examples open on JSONC.
3. Read `/docs/guides/local-development/cli/config-formats`.
4. Open `/docs/reference/cli/supabase-config-convert` and
`/docs/reference/cli/supabase-config-validate`.

## Self-review

Ran the `review-the-docs` local self-review (content, pipeline, and
component checks) over the 54 changed pages.

- No blockers. Fixed the nits it found: leftover TOML section syntax in
prose (diff engines, declarative schemas, Branching, the common settings
table on Local and hosted projects), a few long or ungrammatical
sentences, and the conversion follow-up steps on Config file formats,
now a list.
- Links, custom anchors, nav wiring, and frontmatter check out.
- The `.md` export on the preview shows each TOML example followed by
its JSONC version.
- `test-the-docs` deferred: the changed fences are config snippets, and
`ConfigFormats.test.ts` already converts every tagged example. No
procedural steps changed apart from the `config convert` and `config
validate` commands on the new page.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-20 14:34:59 +00:00

246 lines
6.1 KiB
Plaintext

---
id: 'functions-deploy'
title: 'Deploy to Production'
description: 'Deploy your Edge Functions to your remote Supabase Project.'
subtitle: 'Deploy your Edge Functions to your remote Supabase Project.'
tocVideo: 'EQ5h3NSWMbk'
---
Once you have developed your Edge Functions locally, you can deploy them to your Supabase project.
<Admonition type="note">
Before getting started, make sure you have the Supabase CLI installed. Check out the CLI installation guide for installation methods and troubleshooting.
</Admonition>
---
## Step 1: Authenticate
Sign in to the Supabase CLI if you haven't already:
```bash
supabase login
```
---
## Step 2: Connect your project
Get the project ID associated with your function:
```bash
supabase projects list
```
<Admonition type="note" title="Need a new project?">
If you haven't yet created a Supabase project, you can do so by visiting [database.new](https://database.new).
</Admonition>
[Link](/docs/reference/cli/usage#supabase-link) your local project to your remote Supabase project using the ID you retrieved:
```bash
supabase link --project-ref your-project-id
```
Now you should have your local development environment connected to your production project.
---
## Step 3: Deploy Functions
You can deploy all edge functions within the `functions` folder with a single command:
```bash
supabase functions deploy
```
Or deploy individual Edge Functions by specifying the function name:
```bash
supabase functions deploy hello-world
```
If a deployment fails, see [Edge Function fails to deploy](/kb/troubleshooting/edge-function-fails-deploy).
## Step 4: Verify successful deployment
🎉 Your function is now live!
When the deployment is successful, your function is automatically distributed to edge locations worldwide. Your edge functions is now running globally at `https://[YOUR_PROJECT_ID].supabase.co/functions/v1/hello-world.`
---
## Step 5: Test your live function
You can now invoke your Edge Function using one of the project's `PUBLISHABLE_KEYS`, which can be found in the [API settings](/dashboard/project/_/settings/api) of the Supabase Dashboard. You can invoke it from within your app:
<$CodeTabs>
```bash name=cURL
curl --request POST 'https://<project_id>.supabase.co/functions/v1/hello-world' \
--header 'apikey: PUBLISHABLE_KEY' \
--header 'Content-Type: application/json' \
--data '{ "name":"Functions" }'
```
```js name=JavaScript
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'sb_publishable_...')
const { data, error } = await supabase.functions.invoke('hello-world', {
body: { name: 'Functions' },
})
```
</$CodeTabs>
<Admonition type="note">
Note that the `SUPABASE_PUBLISHABLE_KEYS` is different in development and production. To get a publishable key, you can find it in your Supabase dashboard under Settings > API.
</Admonition>
You should now see the expected response:
```json
{ "message": "Hello Production!" }
```
<Admonition type="note">
You can also test the function through the Dashboard. To see how that works, check out the [Dashboard Quickstart guide](/docs/guides/functions/quickstart-dashboard).
</Admonition>
---
## CI/CD deployment
You can use popular CI / CD tools like GitHub Actions, Bitbucket, and GitLab CI to automate Edge Function deployments.
### GitHub Actions
You can use the official [`setup-cli` GitHub Action](https://github.com/marketplace/actions/supabase-cli-action) to run Supabase CLI commands in your GitHub Actions.
The following GitHub Action deploys all Edge Functions any time code is merged into the `main` branch:
```yaml
name: Deploy Function
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
PROJECT_ID: your-project-id
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- run: supabase functions deploy --remote=$PROJECT_ID --yes
```
---
### GitLab CI
Here is the sample pipeline configuration to deploy via GitLab CI. Set `SUPABASE_ACCESS_TOKEN` and `SUPABASE_PROJECT_ID` as CI/CD variables in your GitLab project.
```yaml
image: node:20
# List of stages for jobs, and their order of execution
stages:
- setup
- deploy
# This job runs in the setup stage, which runs first.
setup-npm:
stage: setup
script:
- npm i supabase
cache:
paths:
- node_modules/
artifacts:
paths:
- node_modules/
# This job runs in the deploy stage, which only starts when the job in the build stage completes successfully.
deploy-function:
stage: deploy
script:
- npx supabase functions deploy --debug --yes
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
```
---
### Bitbucket Pipelines
Here is the sample pipeline configuration to deploy via Bitbucket. Set `SUPABASE_ACCESS_TOKEN` and `SUPABASE_PROJECT_ID` as repository variables.
```yaml
image: node:20
pipelines:
default:
- step:
name: Setup
caches:
- node
script:
- npm i supabase
- parallel:
- step:
name: Functions Deploy
script:
- npx supabase functions deploy --debug --yes
services:
- docker
```
---
### Function configuration
Individual function configuration like [JWT verification](/docs/guides/local-development/cli/config#functions.function_name.verify_jwt) and [import map location](/docs/guides/local-development/cli/config#functions.function_name.import_map) can be set in your config file (`supabase/config.toml` or `supabase/config.jsonc`).
```toml supabase/config.toml
[functions.hello-world]
verify_jwt = false
```
This ensures your function configurations are consistent across all environments and deployments.
---
### Example
This example shows a GitHub Actions workflow that deploys all Edge Functions when code is merged into the `main` branch.
<$CodeSample
meta="deploy.yaml"
path="/edge-functions/.github/workflows/deploy.yaml"
/>