You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
!!! 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.
5
5
6
6
## Overview
7
7
8
8
[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.
9
9
10
+

11
+
10
12
Discover more about Supabase [here](https://supabase.com/docs).
11
13
12
14
To incorporate Supabase into your GPT Engineer application, start with these steps:
13
15
14
16
## Supabase setup
15
17
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:
17
19
18
20
### Step 1: Create a Supabase account
19
21
@@ -23,86 +25,23 @@ Register a new Supabase account [here](https://app.supabase.com/sign-up) or [sig
23
25
24
26
Click on + New Project, complete the necessary fields, and allow a few minutes for setup.
25
27
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
34
29
35
30
Link your GPT Engineer app with the necessary keys.
36
31
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.
38
33
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.
41
35
42
36
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.
43
37
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
100
39
101
40
This section details how to integrate the Supabase Authentication service into your GPT Engineer project, providing specific guidelines for setup and usage.
102
41
103
42
### Initial setup
104
43
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.
106
45
107
46
To add a basic login page to your project, simply run a prompt similar to the one below.
108
47
@@ -112,47 +51,37 @@ To add a basic login page to your project, simply run a prompt similar to the on
112
51
```
113
52
Add login
114
53
```
54
+
You can then create a user by either:
115
55
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
116
58
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".
130
60
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
132
62
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.
139
64
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:
141
66
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.
143
70
144
-
### Row Level Security & Policies
71
+
##Edge Functions
145
72
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
147
78
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.
149
80
150
-
## Video tutorial
81
+
When troublehsooting, you can visit the the logs for your Edge Function in Supabase -> Functions -> Logs.
151
82
152
-
### Building a fullstack app with GPT Engineer and Supabase
83
+
##Best Practices
153
84
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.
155
87
156
-
<divalign="center">
157
-
<iframewidth="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>
0 commit comments