Skip to content

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

Fix Discord icon

Terry Sutton1f573602881c
diff --git a/apps/temp-docs/components/nav/NavBar.tsx b/apps/temp-docs/components/nav/NavBar.tsx
index c60f59d56e6..35f16858802 100644
--- a/apps/temp-docs/components/nav/NavBar.tsx
+++ b/apps/temp-docs/components/nav/NavBar.tsx
@@ -91,9 +91,9 @@ const NavBar = ({ currentPage }: { currentPage: string }) => {
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
>
<path d="m8 17-.55 2C5.5 18.5 3.5 17.5 2 16.27 2 11 3.5 7.5 5 5c0 0 2.5-1 4.5-1l.5 1.36a4.82 4.82 0 0 1 4 .14l.5-1.5c2 0 4.5 1 4.5 1 1.5 2.5 3 6 3 11.27A14.68 14.68 0 0 1 16.55 19L16 17" />
<path d="M7.5 16.5c.73.5 2 1.5 4.5 1.5s3.77-1 4.5-1.5" />
diff --git a/apps/temp-docs/docs/guides/local-development.mdx b/apps/temp-docs/docs/guides/local-development.mdx
index 441d11a8982..2630a3b09c8 100644
--- a/apps/temp-docs/docs/guides/local-development.mdx
+++ b/apps/temp-docs/docs/guides/local-development.mdx
@@ -5,75 +5,78 @@ description: How to use Supabase on your local development machine.
---
import Tabs from '@theme/Tabs'
-import TabsPanel from '@theme/TabsPanel'
+import TabItem from '@theme/TabItem'
-Supabase provides a CLI so that you can develop your application locally, rather than connecting to a live project.
+Learn how to use the Supabase CLI to develop your project locally and deploy to the Supabase Platform.
-## Before you begin
+## Prerequisites
+
+Make sure you have these installed on your local machine:
-If you're using the CLI, please record your steps! You can help us improve by adding missing details and fixing errors.
+- [Docker](https://docs.docker.com/engine/install/)
+- [Git](https://github.com/git-guides/install-git)
+- [Supabase CLI](/docs/guides/cli)
-Our CLI is still under heavy development, and is missing some features:
+## Log in to the Supabase CLI
-- The self-hosted version of Supabase does not include a UI yet.
- We are working on this in stages, starting with our [UI library](https://github.com/supabase/ui)
- ([more context](https://github.com/supabase/supabase/discussions/1001#discussioncomment-558696)).
+```bash
+supabase login
+```
-In the meantime, here are some suggested tools for interacting with your Postgres Database:
+## Initialize your project
-- `pgadmin`: https://www.pgadmin.org
-- `dbeaver`: https://dbeaver.com
-- `BeeKeeper`: https://beekeeperstudio.io
-- `HeidiSQL`: https://heidisql.com
-- `Table Plus`: https://www.tableplus.io
+Create a new folder for your project and start a new git repository:
-## Prerequisites
+```bash
+# create your project folder
+mkdir your-project
-You will need to have these in your environment:
+# move into the new folder
+cd your-project
-- Git
-- Docker (make sure the daemon is up and running)
-- Supabase CLI (instructions [here](https://github.com/supabase/cli))
+# start a new git repository
+git init
+```
-## Initialize your project
+```js
+function create() {
+ console.log('hay')
+}
+```
+
+## Start Supabase services
+
+[Initialize](/reference/cli/usage#supabase-init) Supabase to set up the configuration for developing your project locally:
```bash
supabase init
```
-This command will create a `supabase` folder which holds all the configuration for developing your project locally.
-
-## Start
+Make sure Docker is running. The [start](/reference/cli/usage#supabase-start) command uses Docker to start the Supabase [services](/architecture).
+This command may take a while to run if this is the first time using the CLI.
```bash
supabase start
```
-This command uses Docker Compose to start all the open source [services](/docs/#how-it-works) of Supabase. This command will take a while to run, there are a lot of services to build.
+Once all of the Supabase services are running, you'll see output containing your local Supabase credentials.
+You can use the [stop](/reference/cli/usage#supabase-stop) command at any time to stop all services.
-Once this is running, you will see an output that contains your local Supabase credentials:
+## Access services
-```txt
-Started local development setup.
-API URL: http://localhost:54321
-DB URL: postgresql://postgres:postgres@localhost:5432/postgres
-anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiJ9.ZopqoUt20nEV9cklpv9e3yw3PVyZLmKs5qLD6nGL1SI
-service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIn0.M2d2z4SFn5C7HlJlaSLfrzuYim9nbY_XI40uWFN3hEE
-```
-
-#### Accessing Services Directly
+You can access services directly with any Postgres client or through the API Gateway ([Kong](https://github.com/Kong/kong)).
<Tabs
-defaultActiveId="Postgres"
-values={[
- {label: 'Postgres', value: 'Postgres'},
- {label: 'API Gateway', value: 'Kong'},
-]}>
-<TabsPanel id="Postgres" label="Postgres">
+ defaultValue="postgres"
+ values={[
+ {label: 'Postgres', value: 'postgres'},
+ {label: 'API Gateway', value: 'kong'},
+ ]}>
+<TabItem value="postgres">
```sh
# Default URL:
-postgresql://postgres:postgres@localhost:5432/postgres
+postgresql://postgres:postgres@localhost:54322/postgres
```
The local Postgres instance can be accessed through [`psql`](https://www.postgresql.org/docs/current/app-psql.html)
@@ -82,89 +85,146 @@ or any other Postgres client, such as [pgadmin](https://www.pgadmin.org/).
For example:
```bash
-psql 'postgresql://postgres:postgres@localhost:5432/postgres'
+psql 'postgresql://postgres:postgres@localhost:54322/postgres'
```
-</TabsPanel>
-<TabsPanel id="Kong" label="Kong">
+</TabItem>
+<TabItem value="kong">
```sh
# Default URL:
http://localhost:54321
```
-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](/docs/learn/auth-deep-dive/auth-deep-dive-jwts).
+Learn more about JWT headers in our [Resources](/learn/auth-deep-dive/auth-deep-dive-jwts).
```sh
curl 'http://localhost:54321/rest/v1/' \
- -H "apikey: SUPABASE_KEY" \
- -H "Authorization: Bearer SUPABASE_KEY"
+ -H "apikey: <anon key>" \
+ -H "Authorization: Bearer <anon key>"
-http://localhost:54321/v1/rest/v1/ # REST (PostgREST)
-http://localhost:54321/v1/realtime/v1/ # Realtime
-http://localhost:54321/v1/storage/v1/ # Storage
-http://localhost:54321/v1/auth/v1/ # Auth (GoTrue)
+http://localhost:54321/rest/v1/ # REST (PostgREST)
+http://localhost:54321/realtime/v1/ # Realtime
+http://localhost:54321/storage/v1/ # Storage
+http://localhost:54321/auth/v1/ # Auth (GoTrue)
```
-</TabsPanel>
+</TabItem>
</Tabs>
-## Example application
+:::note
+To access the database from an edge function in your local Supabase setup, replace `localhost` with `host.docker.internal`.
+:::
-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 guide will show you, how you can configure a React app which uses the Supabase stack.
+## Database migrations
-```bash
-# create a fresh React app
-npx create-react-app react-demo --use-npm
+Database changes are managed through "migrations." Database migrations are a common way of tracking changes to your database over time.
-# move into the new folder
-cd react-demo
+### Make database changes
-# set up Supabase
-supabase init
+For this guide, create a table called `employees`. In Supabase Studio, navigate to the **SQL Editor** page and run the following SQL command:
-# Save the install supabase-js library
-npm install --save @supabase/supabase-js
+```sql
+create table employees (
+ id integer primary key generated always as identity,
+ name text
+);
```
-Now that your application is prepared, start the backend:
+:::note
+You can execute any SQL using the `DB URL` shown by [`supabase status`](/reference/cli/usage#supabase-status).
+:::
+
+Run the [`db diff`](/reference/cli/usage#supabase-db-diff) command to detect changes in the local database:
+
+```sh
+supabase db diff create_employees -f create_employees
+```
+
+This creates a new migration named `supabase/migrations/<timestamp>_create_employees.sql`, representing any changes made to the local database since [`supabase start`](/reference/cli/usage#supabase-start).
+
+### Add sample data
+
+Use the seed script in `supabase/seed.sql` (created with [`supabase init`](/reference/cli/usage#supabase-init)) to add sample data to the table.
+
+```sql
+-- in supabase/seed.sql
+insert into public.employees (name)
+values
+ ('Erlich Backman'),
+ ('Richard Hendricks'),
+ ('Monica Hall');
+```
+
+Rerun the migration and seed scripts:
```bash
-supabase start # Start Supabase
+supabase db reset
```
-You can use Supabase anywhere in your application. Copy this snippet into `App.js`:
+You should now see the contents of `employees` in Studio.
-```js
-import { createClient } from '@supabase/supabase-js'
+### Reset database changes
+
+Use the [`reset`](/reference/cli/usage#supabase-db-reset) command to revert any changes to the local database.
+
+```sql
+-- run on local database to make a change
+alter table employees
+ add department text default 'Hooli';
+```
-const SUPABASE_URL = '<your API URL>'
-const SUPABASE_ANON_KEY = '<your anon key>'
+Run the following command to reset the local database:
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
+```sh
+supabase db reset
```
-Then start the frontend in a separate terminal:
+## Deploy your project
+
+Go to the [Supabase Dashboard](https://app.supabase.com) and create a project to deploy the changes.
+
+### Link your project
+
+:::note
+There are a few commands required to link your project. We are in the process of consolidating these commands into a single command. Bear with us!
+:::
+
+Associate your project with your remote project using [`supabase link`](/reference/cli/usage#supabase-link).
```bash
-npm start # Start the React app
+supabase link --project-ref <project-id>
+# You can get <project-id> from your project’s dashboard URL: https://app.supabase.com/project/<project-id>
+
+supabase db remote commit
+# Capture any changes that you have made to your database before setting up the CLI
```
-If everything is working, you should have a React app running on `http://localhost:3000` and Supabase services running on `http://localhost:54321`
+`supabase/migrations` is now populated with a migration in `..._remote_commit.sql`.
+This migration captures any changes required for your local database to match the schema of your remote Supabase project.
-## Stop
+### Deploy database changes
-When you're finished with Supabase, send <kbd>Ctrl-C</kbd> to stop the Docker services.
+Deploy any local database migrations using [`db push`](/reference/cli/usage#supabase-db-push):
-## Migrations
+```sh
+supabase db push
+```
+
+### Deploy Edge Functions
+
+Deploy any Edge Functions using [`functions deploy`](/reference/cli/usage#supabase-functions-deploy):
+
+```sh
+supabase functions deploy <function_name>
+```
-You can also use the CLI to manage your migrations. Follow the the tour [here](https://github.com/supabase/cli/tree/main/examples/tour) to get started.
+## Limitations
-## Next steps
+The local development environment is not as feature-complete as the Supabase Platform. Here are some of the differences:
-- Got a question? [Ask here](https://github.com/supabase/supabase/discussions).
-- CLI repository: [GitHub](https://github.com/supabase/cli).
-- Sign in: [app.supabase.com](https://app.supabase.com)
+- The Storage interface is coming soon.
+- The Functions interface is coming soon.
+- Logs are not supported through the interface (however you can access them through the Docker containers).
+- You cannot update your project settings in the Dashboard—this must be done using the CLI.