The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adds the edge examples
Copplec7eea7ed9025
diff --git a/web/docs/guides/functions.mdx b/web/docs/guides/functions.mdxindex ad7088a6249..683ccc7d27b 100644--- a/web/docs/guides/functions.mdx+++ b/web/docs/guides/functions.mdx@@ -1,16 +1,31 @@---id: functionstitle: Edge Functions-description: 'Examples you can use to get started with Supabase'+description: 'Globally distributed Typescript functions.'---+import Tabs from '@theme/Tabs'+import TabItem from '@theme/TabItem'+const examples = [+ {+ name: 'With supabase-js',+ description: 'Use the Supabase client inside your Edge Function.',+ href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions',+ },+ {+ name: 'With Stripe',+ description: 'Use the Stripe client inside your Edge Function.',+ href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions',+ },+]+:::cautionEdge Functions are Experimental until 1 August 2022. There will breaking changes. Do not use them in Production.:::-Edge Functions are server-side Typescript functions, distributed globally at the edge - close to your users. They can be used for listening to webhooks or integrating your Supabase project with third-parties, like Stripe.+Edge Functions are server-side Typescript functions, distributed globally at the edge - close to your users. They can be used for listening to webhooks or integrating your Supabase project with third-parties, like Stripe.Edge Functions are developed using [Deno](https://deno.com), which offers a few benefits to you as a developer:@@ -39,23 +54,22 @@ Learn how to develop Edge Functions in less than 7 minutes:allowFullScreen></iframe>-## PrerequisitesFollow the steps to prepare your Supabase project on your local machine.- Install the Supabase CLI. [Installing and Updating Docs](/docs/reference/cli/installing-and-updating).- Login to the CLI- - Command: `supabase login`- - Docs: [`login`](/docs/reference/cli/supabase-login)+ - Command: `supabase login`+ - Docs: [`login`](/docs/reference/cli/supabase-login)- Initialize Supabase inside your project- - Command: `supabase login`- - Docs: [Getting Started](/docs/guides/local-development#getting-started)+ - Command: `supabase login`+ - Docs: [Getting Started](/docs/guides/local-development#getting-started)- Link to your Remote Project- - Command: `supabase link --project-ref your-project-ref`- - Docs: `[link](/docs/reference/cli/supabase-link)`+ - Command: `supabase link --project-ref your-project-ref`+ - Docs: `[link](/docs/reference/cli/supabase-link)`- Optional- - Follow [this setup guide](https://deno.land/manual/getting_started/setup_your_environment) to integrate the Deno language server with your editor.+ - Follow [this setup guide](https://deno.land/manual/getting_started/setup_your_environment) to integrate the Deno language server with your editor.## Getting Started@@ -69,7 +83,7 @@ Let's create a new Edge Function called `hello-world` inside your project:supabase functions new hello-world```-This creates a function stub in your `supabase` folder at `./functions/hello-world/index.ts`.+This creates a function stub in your `supabase` folder at `./functions/hello-world/index.ts`.### Deploy to production@@ -79,7 +93,7 @@ supabase functions deploy hello-worldThis command bundles and deploys your Edge Function from `./functions/hello-world/index.ts`-- [ ] TODO - output the URL after running deploy+- [ ] TODO - output the URL after running deploy### Executing Remote Functions@@ -121,13 +135,13 @@ curl --request POST 'http://localhost:54321/functions/v1/hello-world' \```- Implementation details- - All Edge Functions are `POST` requests.- - 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`)+ - All Edge Functions are `POST` requests.+ - 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`)You should see the response `{ "message":"Hello Functions!" }`.-If you execute Function with a different payload the response will change. Try modifying the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'`.+If you execute Function with a different payload the response will change. Try modifying the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'`.## Secrets and Environment Variables@@ -154,7 +168,7 @@ Let's create a local file for storing our secrets, and inside it we can store aecho "MY_NAME=Yoda" >> ./supabase/.env.local```-This creates a new file `./supabase/.env.local` for storing your local development secrets.+This creates a new file `./supabase/.env.local` for storing your local development secrets.:::caution@@ -188,10 +202,10 @@ After invoking the function you should see the name “Yoda” output to the terLet's create a `.env` for production. In this case we'll just use the same as our local secrets:```bash-cp ./supabase/.env.local ./supabase/.env.+cp ./supabase/.env.local ./supabase/.env.```-This creates a new file `./supabase/.env` for storing your production secrets.+This creates a new file `./supabase/.env` for storing your production secrets.:::caution@@ -220,6 +234,21 @@ supabase secrets listYou can find a list of useful [Edge Function Examples](https://github.com/supabase/supabase/tree/master/examples/flutter-user-management) in our GitHub repository.+<div class="container" style={{ padding: 0 }}>+ <div class="row is-multiline">+ {examples.map((x) => (+ <div class="col col--6">+ <a class="card" to={x.href} style={{ height: '100%' }}>+ <div class="card__body">+ <h4>{x.name}</h4>+ <p>{x.description}</p>+ </div>+ </a>+ </div>+ ))}+ </div>+</div>+## Limitations and Suggestions### Organizing your Edge Functions@@ -231,7 +260,7 @@ We recommend developing “fat functions”. This means that you should develop├── functions│ ├── _shared│ │ ├── supabaseAdmin.ts # Supabase client with SERVICE_ROLE key- │ │ └── supabaseClient.ts # Supabase client with ANON key+ │ │ └── supabaseClient.ts # Supabase client with ANON key│ ├── function-one # use hyphens to name functions│ │ └── index.ts│ └── function-two@@ -249,9 +278,9 @@ We recommend using hyphens to name functions because hyphens are the most URL-frEdge Functions are Experimental. They aren't going away, but there will be breaking changes.- Deno Deploy limitations- - Deno does not support outgoing connections to ports `25`, `465`, and `587`.- - Cannot write to File System+ - Deno does not support outgoing connections to ports `25`, `465`, and `587`.+ - Cannot write to File System- Edge Functions- - Local development - only one function at a time- - Supabase Functions only supports `POST` responses.- - Supabase Functions does not support HTML responses.\ No newline at end of file+ - Local development - only one function at a time+ - Supabase Functions only supports `POST` responses.+ - Supabase Functions does not support HTML responses.diff --git a/web/sidebars.js b/web/sidebars.jsindex 961dfd8ab69..889ed674fc5 100755--- a/web/sidebars.js+++ b/web/sidebars.js@@ -111,6 +111,12 @@ module.exports = {collapsed: false,items: ['guides/api'],},+ {+ type: 'category',+ label: 'Functions',+ collapsed: false,+ items: ['guides/functions'],+ },{type: 'category',label: 'Auth',