Skip to content

Commit 0c0db34

Browse files
Merge pull request #6 from lovablelabs/supabase-docs
updated supabase docs
2 parents e8a2b02 + 72d0a67 commit 0c0db34

File tree

2 files changed

+31
-102
lines changed

2 files changed

+31
-102
lines changed

src/assets/supabase.png

372 KB
Loading

src/integrations/supabase.md

Lines changed: 31 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# :simple-supabase: Supabase Integration
22

3-
!!! warning "Supabase integration is in early alpha"
4-
We made Supabase integration available to all our users, but we want to emphasize that it's still in early alpha and that changes are likely.
3+
!!! warning "Supabase integration is in early beta"
4+
We have made the new Supabase integration available to select users. It's still in early beta. If you are interested in joining the beta, please contact us.
55

66
## Overview
77

88
[Supabase](https://supabase.com/) is an open-source alternative to Firebase, offering real-time databases, authentication services, and file storage. It is built atop [PostgreSQL](https://www.postgresql.org/), providing robust SQL querying capabilities and seamless integration with existing tools and frameworks. Supabase also features an intuitive web interface for effortless management of users and data.
99

10+
![Supabase](../assets/supabase.png)
11+
1012
Discover more about Supabase [here](https://supabase.com/docs).
1113

1214
To incorporate Supabase into your GPT Engineer application, start with these steps:
1315

1416
## Supabase setup
1517

16-
Connecting your GPT Engineer app to Supabase is straightforward. Input your Supabase API URL and Anon Key under the project settings tab to access your data within the GPT Engineer environment. This setup allows you to authenticate users and manage data effortlessly.
18+
Connecting your GPT Engineer app to Supabase is straightforward. Simply follow the steps following steps:
1719

1820
### Step 1: Create a Supabase account
1921

@@ -23,86 +25,23 @@ Register a new Supabase account [here](https://app.supabase.com/sign-up) or [sig
2325

2426
Click on + New Project, complete the necessary fields, and allow a few minutes for setup.
2527

26-
### Step 3: Create table(s)
27-
28-
Create table(s) as needed. If you're starting out, consider turning off the Enable Row Level Security ([RLS](https://supabase.com/docs/guides/database/postgres/row-level-security)) feature to allow unrestricted access to the table data.
29-
30-
!!! warning "On RLS (Row Level Security)"
31-
While deactivating Row Level Security (RLS) facilitates testing and development, it's advisable to activate RLS and configure proper access policies in line with your application's needs before going live.
32-
33-
### Step 4: Connect Supabase to GPT Engineer
28+
### Step 3: Connect Supabase to GPT Engineer
3429

3530
Link your GPT Engineer app with the necessary keys.
3631

37-
In your Supabase project, go to Project Settings > API and copy the Project URL.
32+
In your Supabase project, go to Supabase > Connect Supabase. You will be redirected to a page where you will be able to select the relevant organisation.
3833

39-
- In GPT Engineer, access the Settings pane
40-
- Paste the project URL and anon key (located under Supabase Project API keys) into Project > Supabase
34+
Then, you will be able to select the relevant project within that organisation.
4135

4236
With the completion of these steps, your Supabase setup is ready! You can now proceed to integrate Supabase Authentication and Database functionalities into your app.
4337

44-
!!! info "Updating your Supabase Integration"
45-
Remember to press the "Refresh integration" button after making changes to tables in Supabase to update your project integration accordingly.
46-
47-
## Supabase Database
48-
49-
Supabase offers a comprehensive Postgres database solution. Supabase enhances the PostgreSQL experience by providing tools that simplify database management. These include a table view that resembles a spreadsheet, capabilities to manage and replicate data relationships, a SQL editor, real-time database interactions, automated backups, and easy data import from CSV or Excel files. Additionally, users can activate various PostgreSQL extensions via the Supabase dashboard.
50-
51-
In order to start building UI that uses your data stored in Supabase follow these steps:
52-
53-
### Retrieving data
54-
55-
!!! example "Retrieve data to display current events."
56-
Example prompt:
57-
58-
```
59-
Users should be able to view all upcoming events listed on the events page
60-
```
61-
62-
### Adding data
63-
64-
!!! example "Add new events to keep your content up-to-date."
65-
Example prompt:
66-
67-
```
68-
Users should be able to add new events with detailed information through a form
69-
```
70-
71-
### Updating data
72-
73-
!!! example "Update existing events as needed."
74-
Example prompt:
75-
76-
```
77-
Users should be able to modify details of existing events
78-
```
79-
80-
### Deleting data
81-
82-
!!! example "Remove events that are no longer relevant."
83-
Example prompt:
84-
85-
```
86-
Users should be able to delete events
87-
```
88-
89-
90-
### Adding all of these in one go
91-
92-
!!! example "Manage all aspects of event data through a comprehensive interface."
93-
Example prompt:
94-
95-
```
96-
Users should be able to add, view, update, and delete events seamlessly in the events page
97-
```
98-
99-
## Supabase Authentication
38+
## Adding Authentication with Supabase
10039

10140
This section details how to integrate the Supabase Authentication service into your GPT Engineer project, providing specific guidelines for setup and usage.
10241

10342
### Initial setup
10443

105-
To initiate authentication, ensure that you have already connected Supabase to your project.
44+
To initiate authentication, ensure that you have already connected Supabase project to your GPT Engineer project.
10645

10746
To add a basic login page to your project, simply run a prompt similar to the one below.
10847

@@ -112,47 +51,37 @@ To add a basic login page to your project, simply run a prompt similar to the on
11251
```
11352
Add login
11453
```
54+
You can then create a user by either:
11555

56+
- Creating a user directly via the Supabase Dashboard by navigating Supabase -> Authentication -> Users -> Add user.
57+
- Signing up via the login page you've added
11658

117-
To start making some of your pages available only to logged in users, you will need to tell GPT Engineer to make them protected.
118-
!!! example "Creating protected pages"
119-
Example prompt:
120-
121-
```
122-
Create a protected page for /events
123-
```
124-
125-
To test, you will need to create an account to log in with under supabase -> left sidebar -> authentication -> add user.
126-
127-
## More advanced use cases
128-
129-
### I want users to only see their own data
59+
We recommend that you disable the email verification step for now, which you can do in Supabase -> Authentication -> Providers -> Email -> Disable "Confirm email".
13060

131-
To protect your data and specify user permissions, you need to enable Row Level Security (RLS) and establish policies. This can be done in the Supabase dashboard by navigating to the Table Editor, selecting a table, and activating RLS. Afterward, proceed to Database -> Policies to create policies that determine the actions authenticated and non-authenticated users are allowed to perform.
61+
## Storing data with Supabase
13262

133-
### I want to store additional information about my users
134-
135-
If you want to store additional data about your users (beyond their email), you must create a table to hold your users' information, e.g. their names, and profile pictures.
136-
137-
!!! info
138-
The "users" table in the auth (protected) schema holds private information used by Supabase for authentication purposes, such as emails, encrypted passwords, and confirmation tokens.
63+
Supabase offers a comprehensive Postgres database solution. Supabase enhances the PostgreSQL experience by providing tools that simplify database management. These include a table view that resembles a spreadsheet, capabilities to manage and replicate data relationships, a SQL editor, real-time database interactions, automated backups, and easy data import from CSV or Excel files. Additionally, users can activate various PostgreSQL extensions via the Supabase dashboard.
13964

140-
The easiest way to do this it to navigate to Project -> SQL Editor -> Quickstart and to select the "User management starter" query. Running this will automatically create a Profiles table connected to the `auth.users` table with the following attributes: username, full_name, avatar_url and website.
65+
In order to start building UI that uses your data stored in Supabase simply:
14166

142-
## Troubleshooting
67+
1. Ask GPT Engineer to create a new feature and that you expect the data to be stored in Supabase.
68+
2. GPT Engineer will then provide you with a SQL snippet that you can run in the SQL editor in Supabase to create the table(s).
69+
3. Once you confirm that you have run the SQL snippet, then GPT Engineer will update the UI to allow you to interact with the data stored in Supabase.
14370

144-
### Row Level Security & Policies
71+
## Edge Functions
14572

146-
Often, difficulties in fetching or updating data from Supabase through GPT Engineer workflows are linked to the table's security settings and policies.
73+
You can now also use Edge Functions to add powerful backend features like:
74+
- Using AI to enhance your app's capabilities
75+
- Sending emails to your users
76+
- Processing payments
77+
- Running scheduled tasks
14778

148-
For instance, activating Row-Level Security (RLS) on a Supabase table means you cannot access its data unless a policy is in place that permits everyone to read from that table.
79+
GPT Engineer will write and deploy Edge Functions to your Supabase project when implementing backend functionality.
14980

150-
## Video tutorial
81+
When troublehsooting, you can visit the the logs for your Edge Function in Supabase -> Functions -> Logs.
15182

152-
### Building a fullstack app with GPT Engineer and Supabase
83+
## Best Practices
15384

154-
In this brief tutorial, we are showing you how to build a fullstack app using GPT Engineer and Supabase.
85+
!!! warning "Enable RLS policies before going to production"
86+
Important Note: Before you deploy your app to production or use any real data, you will need to review and set up the appropriate RLS policies. I can help with that.
15587

156-
<div align="center">
157-
<iframe width="560" height="315" src="https://www.youtube.com/embed/6LztQnmRpew?si=bItUu27tvkJx-fTS" title="Build a fullstack app using GPT Engineer and Supabase." frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
158-
</div>

0 commit comments

Comments
 (0)