The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Clean up "Local Development" guide
dannykng390be9ac6b17
diff --git a/apps/reference/docs/guides/cli/local-development.mdx b/apps/reference/docs/guides/cli/local-development.mdxindex 852151011fa..aade041eaa5 100644--- a/apps/reference/docs/guides/cli/local-development.mdx+++ b/apps/reference/docs/guides/cli/local-development.mdx@@ -7,33 +7,25 @@ description: How to use Supabase on your local development machine.import Tabs from '@theme/Tabs'import TabItem from '@theme/TabItem'-Supabase provides a [CLI](https://github.com/supabase/cli) so that you can develop your application locally, with the ability to deploy your application to the Supabase platform.+Learn how to use the Supabase CLI to develop your project locally and deploy to the Supabase Platform.## Prerequisites-### Dependencies+Make sure you have these installed on your local machine:-Before we begin, make sure you have these installed on your local machine:+- [Docker](https://docs.docker.com/engine/install/)+- [Git](https://github.com/git-guides/install-git)+- [Supabase CLI](/docs/guides/cli)-- 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](/reference/cli/installing-and-updating)--### Supabase CLI login--After installing the Supabase CLI you can [log in](/reference/cli/usage#supabase-login) using your Supabase account (sign up at [app.supabase.com](https://app.supabase.com)).+## Log in to the Supabase CLI```bashsupabase login```-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+## Initialize your project-Let's create a new folder on your local machine:+Create a new folder for your project and start a new git repository:```bash# create your project folder@@ -46,42 +38,35 @@ cd your-projectgit init```-These commands will create an empty folder for your project and start a new git repository.+## Start Supabase services-### Initialize Supabase--Let's [initialize](/reference/cli/usage#supabase-init) Supabase inside the folder that you created:+[Initialize](/reference/cli/usage#supabase-init) Supabase to set up the configuration for developing your project locally:```bashsupabase init```-This command will create a `supabase` folder which holds all the configuration for developing your project locally.--## Developing Locally--### Start Supabase+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.```bashsupabase start```-The [start](/reference/cli/usage#supabase-start) command uses Docker to start the open source [services](/architecture) 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.-+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.-### Accessing Services Directly+## Access services++You can access services directly with any Postgres client or through the API Gateway ([Kong](https://github.com/Kong/kong)).<Tabs-defaultValue="Postgres"-values={[- {label: 'Postgres', value: 'Postgres'},- {label: 'API Gateway', value: 'Kong'},-]}>-<TabItem value="Postgres">+ defaultValue="postgres"+ values={[+ {label: 'Postgres', value: 'postgres'},+ {label: 'API Gateway', value: 'kong'},+ ]}>+<TabItem value="postgres">```sh# Default URL:@@ -98,16 +83,15 @@ psql 'postgresql://postgres:postgres@localhost:54322/postgres'```</TabItem>-<TabItem value="Kong">+<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](/learn/auth-deep-dive/auth-deep-dive-jwts).+Learn more about JWT headers in our [Resources](/learn/auth-deep-dive/auth-deep-dive-jwts).```shcurl 'http://localhost:54321/rest/v1/' \@@ -123,21 +107,13 @@ http://localhost:54321/auth/v1/ # Auth (GoTrue)</TabItem></Tabs>-### Database Migrations--Database changes are managed through "migrations". Database migrations are a common way of tracking changes to your database over time.+## Database migrations-#### Making database changes+Database changes are managed through "migrations." Database migrations are a common way of tracking changes to your database over time.-For this guide, let's create a table called `employees`, using the "Supabase Studio" link provided.+### Make database changes-:::note--If you're familiar with databases, you can also execute any SQL using the `DB URL` shown by [`supabase status`](/reference/cli/usage#supabase-status).--:::--Open the Studio, navigate to the "SQL Editor" section, and run the following SQL command:+For this guide, create a table called `employees`. In Supabase Studio, navigate to the **SQL Editor** page and run the following SQL command:```sqlcreate table employees (@@ -146,17 +122,21 @@ create table employees ();```-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 [`db diff`](/reference/cli/usage#supabase-db-diff) command:+:::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:```shsupabase db diff create_employees -f create_employees```-This creates a new migration named `supabase/migrations/<timestamp>_create_employees.sql`, representing any changes we've made to the local database since [`supabase start`](/reference/cli/usage#supabase-start).+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).-#### Adding sample data+### Add sample data-Let's add some sample data into the table. We can use the seed script in `supabase/seed.sql` (which gets created when you run [`supabase init`](/reference/cli/usage#supabase-init)).+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@@ -167,17 +147,17 @@ values('Monica Hall');```-Now run the following to rerun the migration scripts and the seed script:+Rerun the migration and seed scripts:```bashsupabase db reset```-If you look again within Studio, you should now see the contents of `employees`.+You should now see the contents of `employees` in Studio.-#### Resetting database changes+### Reset database changes-If you run any SQL on the local database that you want to revert, you can use the [`reset`](/reference/cli/usage#supabase-db-reset) command.+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@@ -185,30 +165,25 @@ alter table employeesadd department text default 'Hooli';```-To revert this change we can run:+Run the following command to reset the local database:```shsupabase db reset```-And the local database will be reset.+## Deploy your project-## Deploying+Go to the [Supabase Dashboard](https://app.supabase.com) and create a project to deploy the changes.-Now that you've developed an application locally, head over to [app.supabase.com](https://app.supabase.com) and create a project where we can deploy the changes.--### Linking your project+### 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!-:::-Let's associate your project with your remote project using [`supabase link`](/reference/cli/usage#supabase-link).+Associate your project with your remote project using [`supabase link`](/reference/cli/usage#supabase-link).```bash-supabase link --project-ref <project-id># You can get <project-id> from your project’s dashboard URL: https://app.supabase.com/project/<project-id>@@ -216,20 +191,20 @@ 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`.+`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.-### Deploying Database changes+### Deploy database changes-You can deploy any local database migrations using [`db push`](/reference/cli/usage#supabase-db-push):+Deploy any local database migrations using [`db push`](/reference/cli/usage#supabase-db-push):```shsupabase db push```-### Deploying Edge Functions+### Deploy Edge Functions-You can deploy any Edge Functions using [`functions deploy`](/reference/cli/usage#supabase-functions-deploy):+Deploy any Edge Functions using [`functions deploy`](/reference/cli/usage#supabase-functions-deploy):```shsupabase functions deploy <function_name>@@ -237,15 +212,9 @@ supabase functions deploy <function_name>## Limitations-The local development environment is not as feature-complete as the Platform. Here are some of the differences:+The local development environment is not as feature-complete as the Supabase Platform. Here are some of the differences:- The Storage interface is coming soon.- The Functions interface is coming soon.-- Logs are not supported through the interface (however you can accesss them via the docker containers).-- You cannot update your project settings via the Dashboard - this can be done using the CLI instead.--## Next steps--- Got a question? [Ask in our Discussions](https://github.com/supabase/supabase/discussions).-- CLI repository: [GitHub](https://github.com/supabase/cli).-- Sign in: [app.supabase.com](https://app.supabase.com)+- 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.