Skip to content

Commit 11483fd

Browse files
Merge pull request #41 from powersync-community/improve-setup-guide
Improve setup guide
2 parents dbb2afb + 6338771 commit 11483fd

File tree

5 files changed

+43
-69
lines changed

5 files changed

+43
-69
lines changed

.env.cloud.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Cloud Environment Configuration
2+
# Copy this template: `cp .env.cloud.template .env.local`
3+
# Edit .env.local and enter your Supabase and PowerSync project details.
4+
5+
# Supabase Configuration
6+
VITE_SUPABASE_URL=https://<your-project-id>.supabase.co
7+
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.<replace-with-your-anon-key>
8+
9+
# PowerSync Configuration
10+
VITE_POWERSYNC_URL=https://<your-project-id>.powersync.journeyapps.com

.env.local.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# Self-hosted Environment Configuration
12
# Copy this template: `cp .env.local.template .env.local`
23
# Edit .env.local and enter your Supabase and PowerSync project details.
4+
35
VITE_SUPABASE_URL=http://localhost:54321
46
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
57
VITE_POWERSYNC_URL=http://localhost:8080
68

7-
# PowerSync configuration
9+
# Self-hosted PowerSync Configuration
810
PS_POSTGRESQL_URI=postgresql://postgres:postgres@supabase_db_powersync:5432/postgres
911
PS_SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
1012
PS_API_TOKEN=super-secret

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44
node_modules
55
dist
66
.DS_Store
7-
.env.local
8-
.env
9-
.vscode
7+
.vscode

README.md

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,31 @@ npm install
1515
## Local Development
1616

1717
### Prerequisites
18-
- Docker Desktop
18+
You will need the following tools installed on your local machine:
19+
- [Docker](https://docs.docker.com/get-docker/)
1920
- [Supabase CLI](supabase.com/docs/guides/local-development/cli/getting-started)
2021

2122
Follow the two steps below to run the entire PowerSync + Supabase stack locally using Docker without requiring any sign up.
2223

2324
1. Copy the environment template file:
24-
```bash
25-
cp .env.local.template .env.local
26-
```
25+
```bash
26+
cp .env.local.template .env.local
27+
```
2728

2829
2. Run the start-up commands for the various services:
29-
```bash
30-
npm run dev:supabase
31-
npm run dev:powersync
32-
npm run dev:ui
33-
```
30+
```bash
31+
npm run dev:supabase
32+
npm run dev:powersync
33+
npm run dev:ui
34+
```
3435

3536
Navigate to the local Vite URL e.g. http://localhost:5173/ Voilà!
3637

3738
## Cloud Development
3839

3940
To run the hosted versions of PowerSync + Supabase, follow the steps below.
4041

41-
### Prerequisites
42+
### Prerequisites
4243

4344
| Tool/Service | Version / Info | Notes |
4445
|------------------|----------------------------|--------------------------------------------------------|
@@ -49,19 +50,15 @@ To run the hosted versions of PowerSync + Supabase, follow the steps below.
4950
This section guides you through setting up the backend using Supabase and PowerSync. Follow the steps below to configure your backend environment.
5051

5152
#### 1. Setup Supabase
52-
Follow these steps to set up your backend with Supabase and PowerSync (Or you can follow the [guide](https://docs.powersync.com/integration-guides/supabase-+-powersync)).
53+
Follow these steps to set up your backend with Supabase and PowerSync (or you can follow the [guide](https://docs.powersync.com/integration-guides/supabase-+-powersync)).
5354

54-
<details>
55-
<summary><strong>Option 1: Setup using the Supabase Dashboard</strong></summary>
5655

5756
1. [Create a new project on the Supabase dashboard](https://supabase.com/dashboard/projects).
5857
2. Go to the Supabase SQL Editor for your new project and execute the SQL statements in [database.pgsql](database.pgsql) to create the database schema, database functions, and publication needed for PowerSync.
5958
3. Enable "anonymous sign-ins" for the project [here](https://supabase.com/dashboard/project/_/auth/providers) (demo specific)
6059

61-
</details>
62-
6360
<details>
64-
<summary><strong>Option 2: Setup using the Supabase CLI</strong></summary>
61+
<summary><strong>Alternative: Setup using the Supabase CLI</strong></summary>
6562

6663
If you prefer using the Supabase CLI to develop the database locally and push it to a Supabase cloud later, you can set up your project as follows:
6764
1. Login to your Supabase Account `npx supabase login`
@@ -79,30 +76,21 @@ If you prefer using the Supabase CLI to develop the database locally and push it
7976

8077
#### 2. Setup PowerSync Instance and Connect to Supabase
8178

82-
You can set up your PowerSync instance using either the Dashboard or CLI approach:
83-
84-
<details>
85-
<summary><strong>Option 1: Setup using the PowerSync Dashboard</strong></summary>
86-
87-
If you prefer using the web interface:
88-
8979
1. In the [PowerSync dashboard](https://powersync.journeyapps.com/), create a new PowerSync instance:
9080
- Right-click on 'PowerSync Project' in the project tree on the left and click "Create new instance"
9181
- Pick a name for the instance e.g. "PowerSyncDemoInstance" and proceed.
9282

9383
2. In the "Edit Instance" dialog that follows, click on the "Connections" tab:
9484
- Click on the "+" button to create a new database connection.
95-
- Input the credentials from the project you created in Supabase. In the Supabase dashboard, under your project you can go to "Project Settings" and then "Database" and choose "URI" under "Connection string", **untick the "Use connection pooling" option** to use the direct connection, and then copy & paste the connection string into the PowerSync dashboard "URI" field, and then enter your database password at the "Password" field.
85+
- Input the credentials from the project you created in Supabase. Go to [this page](https://supabase.com/dashboard/project/_?showConnect=true), copy & paste the connection string into the PowerSync dashboard "URI" field, and then enter your database password at the "Password" field. However, we do recommend using a dedicated database user for PowerSync, please refer to the [Source database guide](https://docs.powersync.com/installation/database-setup#2-create-a-powersync-database-user)
9686
- Click the "Test connection" button and you should see "Connection success!"
9787

9888
3. Click on the "Credentials" tab of the "Edit Instance" dialog:
9989
- Tick the "Use Supabase Auth" checkbox and configure the JWT secret.
10090
- Click "Save" to save all the changes to your PowerSync instance. The instance will now be deployed — this may take a minute or two.
10191

102-
</details>
103-
10492
<details>
105-
<summary><strong>Option 2: Setup using the PowerSync CLI</strong></summary>
93+
<summary><strong>Alternative: Setup using the PowerSync CLI</strong></summary>
10694

10795
See [PowerSync CLI docs](https://docs.powersync.com/usage/tools/cli).
10896

@@ -117,13 +105,11 @@ If you don't have a PowerSync account yet, [sign up here](https://accounts.journ
117105
- Search for "Create Personal Access Token"
118106
- Give it "owner" policy and a descriptive label
119107
- Copy the generated token
120-
121108
2. **Initialize the CLI and authenticate:**
122109
```bash
123110
npx powersync init
124111
```
125112
Paste your Personal Access Token when prompted.
126-
127113
3. **Create a new PowerSync instance:**
128114
```bash
129115
npx powersync instance create
@@ -135,7 +121,6 @@ Follow the prompts to configure:
135121
- When asked about Supabase auth, answer:
136122
- `? Are you using Supabase auth? Yes`
137123
- `? Do you want to add audiences? No`
138-
139124
4. **Deploy sync rules:**
140125
```bash
141126
npx powersync instance sync-rules deploy -f sync-rules.yaml
@@ -145,29 +130,17 @@ Follow the prompts to configure:
145130
146131
</details>
147132

148-
#### 3. Deploy Sync Rules
149-
150-
<details>
151-
<summary><strong>Option 1: Using CLI (if you used CLI setup above)</strong></summary>
152-
153-
The sync rules are already deployed if you followed the CLI setup steps above.
154-
155-
</details>
156-
157-
<details>
158-
<summary><strong>Option 2: Using Dashboard</strong></summary>
133+
#### 3. Deploy Sync Rules (not needed if using PowerSync CLI)
159134

160135
1. Open the [sync-rules.yaml](sync-rules.yaml) in this repo and copy the contents.
161136
2. In the [PowerSync dashboard](https://powersync.journeyapps.com/), paste that into the 'sync-rules.yaml' editor panel.
162137
3. Click the "Deploy sync rules" button and select your PowerSync instance from the drop-down list.
163138

164-
</details>
165-
166-
#### 4. Set up environment
139+
#### 4. Set environment variables
167140

168141
First, copy the environment template file:
169142
```bash
170-
cp .env.local.template .env.local
143+
cp .env.cloud.template .env.local
171144
```
172145

173146
Then set the following environment variables in your `.env.local` file:
@@ -178,25 +151,16 @@ VITE_SUPABASE_ANON_KEY=
178151
VITE_POWERSYNC_URL=
179152
```
180153

181-
### How to get these values:
182-
183-
**VITE_SUPABASE_URL & VITE_SUPABASE_ANON_KEY:**
184-
185-
**Quick Access:** For convenience, you can access both settings directly:
186-
- [API Settings & URL](https://supabase.com/dashboard/project/_/settings/api)
187-
- [API Keys](https://supabase.com/dashboard/project/_/settings/api-keys)
154+
**Where do you get these values?**
188155

189-
**Detailed Instructions:**
190-
1. Go to your [Supabase Dashboard](https://app.supabase.com)
191-
2. Select your project
192-
3. For the URL: Navigate to Project Settings → Data API and copy the "Project URL" for `VITE_SUPABASE_URL`
193-
4. For the key: Navigate to Project Settings → API Keys and copy the "anon public" key for `VITE_SUPABASE_ANON_KEY`
156+
For Supabase, you can get both settings directly from:
157+
- VITE_SUPABASE_URL - [API Settings & URL](https://supabase.com/dashboard/project/_/settings/api)
158+
- VITE_SUPABASE_ANON_KEY - [API Keys](https://supabase.com/dashboard/project/_/settings/api-keys)
194159

195-
**VITE_POWERSYNC_URL:**
160+
For PowerSync, follow these steps:
196161
1. Go to your [PowerSync Dashboard](https://powersync.journeyapps.com/)
197-
2. Select your project
198-
3. Navigate to your PowerSync instance
199-
4. Copy the "Instance URL" for `VITE_POWERSYNC_URL`
162+
2. Navigate to your PowerSync instance
163+
3. Copy the "Instance URL" for `VITE_POWERSYNC_URL`
200164

201165
## Use this project with bolt.new
202166

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)