The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adds some details for local development
Paul Copplestone211f2888021a
diff --git a/web/docs/guides/local-development.mdx b/web/docs/guides/local-development.mdxnew file mode 100644index 00000000000..8652de28af5--- /dev/null+++ b/web/docs/guides/local-development.mdx@@ -0,0 +1,181 @@+---+id: local-development+title: Local Development+description: How to use Supabase on your local development machine.+---++import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++Supabase provides a CLI so that you can develop your application locally, rather than connecting to a live project.++:::note++Our CLI is still under heavy development, and is missing features which will deploy your local changes to your live project. Our goal is to build+an experience similar to the Firebase [Emulator](https://firebase.google.com/docs/emulator-suite), except that the local version of your application+is exactly the same set up that we use on the platform.++:::+++## Prerequisites++Our CLI makes heavy use of [Docker Compose](https://docs.docker.com/compose/install), so make sure it is installed and configured on your machine before starting.++## Install the CLI++```bash+npx create-react-app react-demo --use-npm+cd create-react-app+```+++## Initialize your project++```bash+supabase init+```++You will be guided through a series of questions, and if everything went well, you will see an output similar to this:++```txt+✔ Port for Supabase URL: · 8000+✔ Port for PostgreSQL database: · 5432+✔ Project initialized.+Supabase URL: http://localhost:8000+Supabase Key: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIiLCJSb2xlIjoicG9zdGdyZXMifQ.magCcozTMKNrl76Tj2dsM7XTl_YH0v0ilajzAvIlw3U+Database URL: postgres://postgres:postgres@localhost:5432/postgres++Run supabase start to start the local emulator.+```++This command will create a `.supabase` folder which holds all the configuration for developing your project locally. You don't need to check this into version control.+++## Start+++```bash+supabase start+```++This command uses Docker Compose to start all the open sources [services](/docs/#how-it-works) of Supabase. This command will take a while to run, there are a lot of services to build.++Once this is running, you will see the healthy services in Docker Dashboard:+++++#### Accessing Services Directly+++<Tabs+defaultValue="Postgres"+values={[+ {label: 'Postgres', value: 'Postgres'},+ {label: 'API Gateway', value: 'Kong'},+]}>+<TabItem value="Postgres">++```sh+# Default URL:+postgres://postgres:postgres@localhost:5432/postgres+```++The local Postgres instance can be accessed through [`psql`](https://www.postgresql.org/docs/current/app-psql.html)+or any other Postgres client, such as [pgadmin](https://www.pgadmin.org/).++For example:++```bash+psql -h localhost -d postgres -U postgres -W++# Enter your password (default is "postgres")+```++</TabItem>+<TabItem value="Kong">++```sh+# Default URL:+http://localhost:8000/v1?apikey=SUPABASE_KEY+```++All of the services are accessible through the API Gateway [Kong](https://github.com/Kong/kong)).+If you are accessing these services without the client libraries, you may need to pass the client keys as an `Authorization` header.+You can learn more about these JWT headers in our [Resources](http://localhost:3005/docs/learn/auth-deep-dive/auth-deep-dive-jwts).+++```sh+curl 'http://localhost:8000/v1' \+ -H "apikey: SUPABASE_KEY" \+ -H "Authorization: Bearer SUPABASE_KEY"++http://localhost:8000/v1/rest/v1/ # REST (PostgREST)+http://localhost:8000/v1/realtime/v1/ # Realtime+http://localhost:8000/v1/storage/v1/ # Storage+http://localhost:8000/v1/auth/v1/ # Auth (GoTrue)+```+++</TabItem>+</Tabs>+++## Example application++Now that we've learned how to install and start Supabase locally, let's see how you can use it with a frontend application.+This quick start will show you how you can configure a React app which uses Supabase stack.++```bash+# create a fresh React app+npx create-react-app react-demo++# move into the new folder+cd react-demo++# set up Supabase+supabase init++# Save the install supabase-js library+npm install --save @supabase/supabase-js+```++Now that your application is now prepared, you can use Supabase anywhere in your application:++```js+import { createClient } from '@supabase/supabase-js'++const SUPABASE_URL = 'http://localhost:8000'+const SUPABASE_ANON_KEY = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIiLCJSb2xlIjoicG9zdGdyZXMifQ.magCcozTMKNrl76Tj2dsM7XTl_YH0v0ilajzAvIlw3U'++const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)+```++Copy this snippet into `App.js`, and then start the backend and the frontend:++```bash+supabase start # Start Supabase+npm start # Start the React app+```++If everything is working you should have a React app running on `http://localhost:3000` and Supabase services running on `http://localhost:8000`++## Stop++```bash+supabase stop+```++When you are finished with Supabase, run `supabase stop` to stop the Docker services.++## Migrations++TBD+++## Next steps++- Got a question? [Ask here](https://github.com/supabase/supabase/discussions).+- CLI repository: [GitHub](https://github.com/supabase/cli).+- Sign in: [app.supabase.io](https://app.supabase.io)diff --git a/web/docs/guides/self-hosting.mdx b/web/docs/guides/self-hosting.mdxindex e91788a88eb..81b850ffd54 100644--- a/web/docs/guides/self-hosting.mdx+++ b/web/docs/guides/self-hosting.mdx@@ -1,62 +1,33 @@---id: self-hosting-title: Local Development and Self Hosting-description: How to use.+title: Self Hosting+description: How to use configure and deploy Supabase.---+Supabase is a [Hosted Platform](https://app.supabase.io), so you don't _have_ to deploy it yourself.+However, if you _want_ to configure and deploy it yourself, this is also possible.-You can develop an application either locally and deploy to a service of your choice, or using our hosted platform.-## Local development-Local development (will be released 1 April). Our CLI makes heavy use of [Docker](https://www.docker.com/), so make sure it is installed and configured on your machine before starting.+## Get the Docker Compose-### Install our CLI--```bash-npm install -g supabase-```--### Initialize your project--```bash-supabase init-```--This command will create a `.supabase` folder which holds all the configuration for developing your project locally.--### Start--```bash-supabase start-```+You can download this Docker set up to your local machine in various ways:-This command uses Docker Compose to start all the services that make up Supabase. You can find the full Docker Compose [in our repo](https://github.com/supabase/supabase/blob/master/docker).+### Option 1: Using our CLI-### Stop+Make sure the CLI is installed:```bash-supabase stop+npm install -g supabase```-## Self hosting--Every Supabase project is an amalgamation of open source tools. We provide a [Docker Compose](https://github.com/supabase/supabase/blob/master/docker) setup which makes it simple to get started.---### Get the Docker Compose--You can download this Docker set up to your local machine in various ways:--#### Using our CLI (will be released 1 April).+Then run in any folder to create a `docker` folder with a `docker-compose.yml`:```bashsupabase eject```-Run this in any folder to create a `docker` folder with a `docker-compose.yml`--#### Clone our repo+### Option 2: Clone our repo```bash# 1. Copy an empty repo@@ -66,7 +37,7 @@ git clone https://github.com/supabase/supabasecd supabase/docker```-#### Using a shallow clone+### Option 3: Using a shallow cloneIf you use Git version >2.25, you can use a shallow clone to download this folder to your local machine:@@ -80,7 +51,7 @@ cd supabase# 3. Initialize sparse-checkoutgit sparse-checkout init --cone-#4. Checkout the folder+# 4. Checkout the foldergit sparse-checkout set docker```diff --git a/web/sidebars.js b/web/sidebars.jsindex 17a80c50c39..d353899a9c6 100755--- a/web/sidebars.js+++ b/web/sidebars.js@@ -74,6 +74,7 @@ module.exports = {'guides/auth','guides/storage','guides/client-libraries',+ 'guides/local-development','guides/self-hosting',],},diff --git a/web/static/img/docker-supabase.png b/web/static/img/docker-supabase.pngnew file mode 100644index 00000000000..5750220ccdbBinary files /dev/null and b/web/static/img/docker-supabase.png differ