Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: review changes.

thorwebdev5037ee95e5e4
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index 75d54fb2afb..e46dafbf7df 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -421,12 +421,13 @@ export const functions = {
label: 'Edge Functions',
url: '/guides/functions',
items: [
- { name: 'Overview', url: '/guides/functions/overview', items: [] },
+ { name: 'Quickstart', url: '/guides/functions/quickstart', items: [] },
{ name: 'Auth', url: '/guides/functions/auth', items: [] },
{ name: 'CORS', url: '/guides/functions/cors', items: [] },
{ name: 'CI/CD Workflow', url: '/guides/functions/cicd-workflow', items: [] },
+ { name: 'Debugging', url: '/guides/functions/debugging', items: [] },
+ { name: 'Local Development', url: '/guides/functions/local-development', items: [] },
{ name: 'Managing Secrets', url: '/guides/functions/secrets', items: [] },
- { name: 'Testing & Debugging', url: '/guides/functions/testing-debugging', items: [] },
{ name: 'Tips', url: '/guides/functions/tips', items: [] },
{
name: 'Examples',
diff --git a/apps/docs/pages/guides/functions.mdx b/apps/docs/pages/guides/functions.mdx
index 792972fe630..9c970cb6bfe 100644
--- a/apps/docs/pages/guides/functions.mdx
+++ b/apps/docs/pages/guides/functions.mdx
@@ -18,7 +18,7 @@ Edge Functions are server-side TypeScript functions, distributed globally at the
- Edge Functions are globally distributed for low-latency.
<div className="not-prose">
- <Button as="a" href="/docs/guides/functions/overview" size="medium">
+ <Button as="a" href="/docs/guides/functions/quickstart" size="medium">
Get started
</Button>
</div>
diff --git a/apps/docs/pages/guides/functions/cors.mdx b/apps/docs/pages/guides/functions/cors.mdx
index fca25fa4933..e991ad181a9 100644
--- a/apps/docs/pages/guides/functions/cors.mdx
+++ b/apps/docs/pages/guides/functions/cors.mdx
@@ -12,7 +12,7 @@ See the [example on GitHub](https://github.com/supabase/supabase/blob/master/exa
### Recommended setup
-We recommend adding a `corst.ts` file within a `_shared` folder which makes it easy to reuse the CORS headers across functions:
+We recommend adding a `corst.ts` file within a [`_shared` folder](/docs/guides/functions/tips#organizing-your-edge-functions) which makes it easy to reuse the CORS headers across functions:
```ts cors.ts
export const corsHeaders = {
diff --git a/apps/docs/pages/guides/functions/debugging.mdx b/apps/docs/pages/guides/functions/debugging.mdx
new file mode 100644
index 00000000000..62c93035b2a
--- /dev/null
+++ b/apps/docs/pages/guides/functions/debugging.mdx
@@ -0,0 +1,20 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'functions-debugging',
+ title: 'Debugging Functions',
+ description: 'Debug functions in production.',
+}
+
+You can debug your deployed Edge Functions using the ["Functions" section](https://app.supabase.com/project/_/functions) of the Dashboard. There are two debugging tools available:
+
+- Invocations: shows the Request and Response for each execution.
+- Logs: shows any platform events, including deployments and errors.
+
+![Function invocations.](/docs/img/guides/functions/function-logs.png)
+
+When [developing locally](/docs/guides/functions/local-development) you will see error messages and console log statements printed to your local terminal window.
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/testing-debugging.mdx b/apps/docs/pages/guides/functions/local-development.mdx
similarity index 64%
rename from apps/docs/pages/guides/functions/testing-debugging.mdx
rename to apps/docs/pages/guides/functions/local-development.mdx
index b0b4cc468dd..01bd0f88a4d 100644
--- a/apps/docs/pages/guides/functions/testing-debugging.mdx
+++ b/apps/docs/pages/guides/functions/local-development.mdx
@@ -1,20 +1,11 @@
import Layout from '~/layouts/DefaultGuideLayout'
export const meta = {
- id: 'functions-testing-debugging',
- title: 'Testing and Debugging Functions',
- description: 'Test and debug functions locally and in production.',
+ id: 'functions-local-development',
+ title: 'Local Development',
+ description: 'Run your functions locally.',
}
-You can debug your deployed Edge Functions using the "Functions" section of the Dashboard. There are two types debugging tools available:
-
-- Invocations: shows the Request and Response for each execution.
-- Logs: shows any platform events, including deployments and errors.
-
-![Function invocations.](/docs/img/guides/functions/function-logs.png)
-
-## Develop locally
-
You can run your Edge Function locally using [`supabase functions serve`](/docs/reference/cli/usage#supabase-functions-serve):
```bash
@@ -26,7 +17,7 @@ The `functions serve` command has hot-reloading capabilities. It will watch for
### Invoke functions locally
-While serving your local Function, you can execute it using curl:
+While serving your local Function, you can invoke it using curl:
```bash
curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
@@ -35,20 +26,34 @@ curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
--data '{ "name":"Functions" }'
```
+or using one of the [client libraries](/docs#reference-documentation), e.g. using [supabase-js](/docs/reference/javascript/functions-invoke):
+
+```js
+import { createClient } from '@supabase/supabase-js'
+
+// Use the credentials outputted in your terminal when running `supabase start`
+const supabase = createClient(
+ 'http://localhost:54321',
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
+)
+
+const { data, error } = await supabase.functions.invoke('hello-world', {
+ body: { name: 'Functions' },
+})
+```
+
You should see the response `{ "message":"Hello Functions!" }`.
-<details>
-<summary>Implementation details</summary>
+If you execute Function with a different payload the response will change. <br />
+Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
+
+<Admonition type="note">
- Edge Functions don't serve HTML content (`GET` requests that return `text/html` are rewritten to `text/plain`).
- The `Authorization` header is required. You can use either the `ANON` key, the `SERVICE_ROLE` key, or a logged-in user's JWT.
- The Function is proxied through the local API (`http://localhost:54321`)
-</details>
-<br />
-
-If you execute Function with a different payload the response will change. <br />
-Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
+</Admonition>
export const Page = ({ children }) => <Layout meta={meta} children={children} />
diff --git a/apps/docs/pages/guides/functions/overview.mdx b/apps/docs/pages/guides/functions/quickstart.mdx
similarity index 97%
rename from apps/docs/pages/guides/functions/overview.mdx
rename to apps/docs/pages/guides/functions/quickstart.mdx
index 49935c280bf..7b489f2009e 100644
--- a/apps/docs/pages/guides/functions/overview.mdx
+++ b/apps/docs/pages/guides/functions/quickstart.mdx
@@ -1,10 +1,10 @@
import Layout from '~/layouts/DefaultGuideLayout'
export const meta = {
- id: 'functions-overview',
- title: 'Edge Functions Overview',
+ id: 'functions-quickstart',
+ title: 'Edge Functions Quickstart',
description: 'Globally distributed TypeScript Functions.',
- sidebar_label: 'Overview',
+ sidebar_label: 'Quickstart',
}
Learn how to build an Edge Function locally and deploy it to the Supabase Platform in less than 7 minutes.
diff --git a/apps/docs/pages/guides/functions/tips.mdx b/apps/docs/pages/guides/functions/tips.mdx
index 8d11169805a..9c96998db4a 100644
--- a/apps/docs/pages/guides/functions/tips.mdx
+++ b/apps/docs/pages/guides/functions/tips.mdx
@@ -21,11 +21,12 @@ We recommend developing “fat functions”. This means that you should develop
└── supabase
├── functions
│ ├── _shared
- │ | ├── supabaseAdmin.ts # Supabase client with SERVICE_ROLE key
- │ │ └── supabaseClient.ts # Supabase client with ANON key
- │ ├── function-one # use hyphens to name functions
- │ │ └── index.ts
- │ └── function-two
+ │ │ ├── supabaseAdmin.ts # Supabase client with SERVICE_ROLE key
+ │ │ └── supabaseClient.ts # Supabase client with ANON key
+ │ │ └── cors.ts # Reusable CORS headers
+ │ ├── function-one # use hyphens to name functions
+ │ │ └── index.ts
+ │ └── function-two
│ └── index.ts
├── migrations
└── config.toml