Skip to content

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

updates the local development guide

Copple59e33ab65e29
diff --git a/web/docs/guides/local-development.mdx b/web/docs/guides/local-development.mdx
index c030ca4973a..bede716ea3f 100644
--- a/web/docs/guides/local-development.mdx
+++ b/web/docs/guides/local-development.mdx
@@ -9,18 +9,32 @@ import TabItem from '@theme/TabItem';
Supabase provides a CLI so that you can develop your application locally, with the ability to deploy your application to the Supabase platform.
-## Getting started
+## Prerequisites
+
+### Dependencies
+
+Before we begin, make sure you have these installed on your local machine:
+
+- Git. [Docs](https://github.com/git-guides/install-git)
+- Docker (make sure this is running). [Docs](https://docs.docker.com/engine/install/)
+- Supabase CLI. [Docs](/docs/reference/cli/installing-and-updating)
-### Prerequisites
+### Supabase CLI login
-You will need to have these in your environment:
+After installing the Supabase CLI you can [log in](/docs/reference/cli/supabase-login) using your Supabase account (sign up at [app.supabase.io](https://app.supabase.io)).
+
+```bash
+supabase login
+```
-- Git
-- Docker (make sure the daemon is up and running)
-- Supabase CLI (instructions [here](https://github.com/supabase/cli))
+This is a one-time operation. After you have logged in the CLI will have permissions to manage your Supabase projects.
+
+## Getting started
### Initialize your project
+Let's create a new folder on your local machine:
+
```bash
# create your project folder
mkdir your-project
@@ -32,34 +46,19 @@ cd your-project
git init
```
-This command will create an empty folder for your project and start a new git repository.
+These commands will create an empty folder for your project and start a new git repository.
### Initialize Supabase
+Let's [initialize](/docs/reference/cli/supabase-init) Supabase inside the folder that you created:
+
```bash
supabase init
```
This command will create a `supabase` folder which holds all the configuration for developing your project locally.
-### Remote project
-
-We can link any local project to a remote database. Use the connection string from your Supabase project here.
-
-```bash
-supabase db remote set 'postgresql://postgres:<your_password>@db.<your_project_ref>.supabase.co:5432/postgres'
-```
-
-After that, run:
-
-```bash
-supabase db remote commit
-```
-
-This command captures any changes that you have made to your database before setting up the CLI.
-
-You'll notice that `supabase/migrations` is now populated with a migration in `..._remote_commit.sql`.
-This migration captures all the changes required on your local database to match the schema of your remote Supabase project.
+## Developing Locally
### Start Supabase
@@ -67,11 +66,13 @@ This migration captures all the changes required on your local database to match
supabase start
```
-The `supabase start` command uses Docker to start the open source [services](/docs/#how-it-works) of Supabase.
+The [start](/docs/reference/cli/supabase-start) command uses Docker to start the open source [services](/docs/#how-it-works) of Supabase.
This command may take a while to run if this is the first time using the CLI.
Once all of the Supabase services are running, you'll see an output that contains your local Supabase credentials.
+You can use the [stop](/docs/reference/cli/supabase-stop) command at any time to stop all services.
+
### Accessing Services Directly
<Tabs
@@ -122,25 +123,23 @@ http://localhost:54321/auth/v1/ # Auth (GoTrue)
</TabItem>
</Tabs>
-### Stop Supabase
-```bash
-supabase stop
-```
+### Database Migrations
+
+Database changes are managed through "migrations". Datbase migrations are a common way of tracking changes to your database over time.
-Stop Supabase services and let's build a real application next.
-## Migrations
+#### Making database changes
-You can also use the CLI to manage your migrations.
+For this guild, let's create a table called `employees`, using the "Supabase Studio" link provided.
+:::note
-## 2. Making database changes
+If you're familiar with databases, you can also execute any SQL using the `DB URL` shown by `supabase start`.
-To modify your local database, simply run some SQL against the `DB URL` shown by `supabase start`.
+:::
-For this example, we'll create a table called `employees`, using the "Supabase Studio" link provided.
-Open the Studio, navigate to the "SQL Editor" section, and then run the following SQL command:
+Open the Studio, navigate to the "SQL Editor" section, and run the following SQL command:
```sql
create table employees (
@@ -149,15 +148,15 @@ create table employees (
);
```
-Now we have the `employees` table in the local database, but how do we incorporate this into migrations? The CLI can automatically detect changes by running:
+Now we have the `employees` table in the local database, but how do we incorporate this into migrations? The CLI automatically detects changes by running the [commit](/docs/reference/cli/supabase-db-commit) command:
```sh
supabase db commit create_employees
```
-This will create a new migration named `<timestamp>_create_employees.sql` that represents any changes we've made to the local database since `supabase start`.
+This creates a new migration named `<timestamp>_create_employees.sql`, representing any changes we've made to the local database since `supabase start`.
-Let's add some sample data into the table. To do this we can use the seed script in `supabase/seed.sql`.
+Let's add some sample data into the table. We can use the seed script in `supabase/seed.sql`.
```sql
-- in supabase/seed.sql
@@ -176,7 +175,7 @@ supabase db reset
If you look again within Studio, you should now see the contents of `employees`.
-## 3. Resetting database changes
+#### Resetting database changes
If you run any SQL on the local database that you want to revert, you can use the `reset` command.
@@ -194,15 +193,49 @@ supabase db reset
And the local database will be reset.
-## 4. Deploying migrations
+## Deploying
+
+Now that you've developed an application locally, head over to [app.supabase.io](https://app.supabase.io) and create a project where we can deploy the changes.
+
+### Linking 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!
+
+:::
+
+Let's associate your project with your remote project using [supabase link](/docs/guides/local-development) and [db remote set](/docs/reference/cli/supabase-db-remote-set)
+
+
+```bash
+
+supabase link
+# Use "supabase link --project-ref your-project-ref" to link your project in one step.
+
+supabase db remote set 'postgresql://postgres:<your_password>@db.<your_project_ref>.supabase.co:5432/postgres'
+# Use the connection string from your Supabase project here.
+
+supabase db remote commit
+# capture any changes that you have made to your database before setting up the CLI
+```
+
+You'll notice that `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.
+
-Finally, we need to deploy these local changes to the remote database (i.e. your remote Supabase project).
-We can do this by running:
+### Deploying Database changes
+
+You can deploy any local database migrations using [`db push`](/docs/reference/cli/supabase-db-push):
```sh
supabase db push
```
+### Deploying Edge Functions
+
+Coming soon!
+
## Next steps
- Got a question? [Ask in our Discussions](https://github.com/supabase/supabase/discussions).