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
Major changes :
* Supabase JS SDK V2 😇
* Folder structure
* Previous module's mutations/queries are now in a `service.server` (collocate all the module's service in one place)
* Auth session is reworked to align with folder structure changes
* `requireAuthSession` no longer call Supabase Auth API by default to verify user access token (it's still safe, we signed our cookie)
* `requireAuthSession` takes a new optional param called `verify` (boolean) to work as before 😉
* No more needing to start a shadow database to create a Prisma migration (I don't know why maybe it's thanks to Supabase). It results in a huge time saving!
- Healthcheck endpoint for [Fly backups region fallbacks](https://fly.io/docs/reference/configuration/#services-http_checks)
18
-
-[GitHub Actions](https://github.com/features/actions) for deploy on merge to production and staging environments
19
-
- Email/Password Authentication with [cookie-based sessions](https://remix.run/docs/en/v1/api/remix#createcookiesessionstorage)
20
-
-**NEW** : Magic Link login 🥳
18
+
-[GitHub Actions](https://github.com/features/actions) to deploy on merge to production and staging environments
19
+
- Email/Password Authentication / Magic Link, with [cookie-based sessions](https://remix.run/docs/en/v1/api/remix#createcookiesessionstorage)
21
20
- Database ORM with [Prisma](https://prisma.io)
22
21
- Forms Schema (client and server sides !) validation with [Remix Params Helper](https://github.com/kiliman/remix-params-helper)
23
22
- Styling with [Tailwind](https://tailwindcss.com/)
@@ -32,7 +31,7 @@ Not a fan of bits of the stack? Fork it, change it, and use `npx create-remix --
32
31
33
32
## Development
34
33
35
-
- Create a [Supabase Database](https://supabase.com/) (Free tiers gives you 2 databases)
34
+
- Create a [Supabase Database](https://supabase.com/) (free tier gives you 2 databases)
36
35
37
36
> **Note:** Only one for playing around with Supabase or 2 for `staging` and `production`
38
37
@@ -84,7 +83,7 @@ The database seed script creates a new user with some data you can use to get st
84
83
85
84
### Relevant code:
86
85
87
-
This is a pretty simple note-taking app, but it's a good example of how you can build a fullstack app with Prisma, Supabase and Remix. The main functionality is creating users, logging in and out (handling access and refresh tokens + refresh on expire), and creating and deleting notes.
86
+
This is a pretty simple note-taking app, but it's a good example of how you can build a full-stack app with Prisma, Supabase, and Remix. The main functionality is creating users, logging in and out (handling access and refresh tokens + refresh on expiration), and creating and deleting notes.
- creating, and deleting notes [./app/modules/note](./app/modules/note)
@@ -197,7 +196,7 @@ For lower level tests of utilities and individual components, we use `vitest`. W
197
196
198
197
### Type Checking
199
198
200
-
This project uses TypeScript. It's recommended to get TypeScript set up for your editor to get a really great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run `npm run typecheck`.
199
+
This project uses TypeScript. It's recommended to get TypeScript set up for your editor to get a great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run `npm run typecheck`.
201
200
202
201
### Linting
203
202
@@ -209,48 +208,30 @@ We use [Prettier](https://prettier.io/) for auto-formatting in this project. It'
209
208
210
209
## Start working with Supabase
211
210
212
-
Your are now ready to go further, congrats !
213
-
214
-
To extend your prisma schema and apply changes on your supabase database :
215
-
216
-
- Download and run [Docker Desktop](https://www.docker.com/products/docker-desktop/)
217
-
218
-
> **Note:** Needed to create a [shadow database for prisma](https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database)
219
-
220
-
> **Note:** Shadow database is local and run by `docker-compose.yml`
211
+
You are now ready to go further, congrats!
221
212
213
+
To extend your Prisma schema and apply changes on your supabase database :
222
214
- Make your changes in [./app/database/schema.prisma](./app/database/schema.prisma)
223
215
- Prepare your schema migration
224
-
225
-
> **Note:** First time take a long moment 😅
226
-
227
216
```sh
228
217
npm run db:prepare-migration
229
218
```
230
-
231
-
- Check your migration in [./app/database/migrations](./app/database/migrations)
232
-
- Apply this migration in production
219
+
- Check your migration in [./app/database/migrations](./app/database)
220
+
- Apply this migration to production
233
221
234
222
```sh
235
223
npm run db:deploy-migration
236
224
```
237
225
238
-
## Use with Supabase RLS
239
-
240
-
> To test this stack with RLS, you can find a demo in [./app/routes/rls](./app/routes/rls)
241
-
242
-
> **Before playing, add some RLS rules for "Note" table**
243
-
244
-
| Policy name | Target roles | WITH CHECK expression |
| Creator can see their own notes | authenticated | ((uid())::text = "userId") |
247
-
| Authenticated user can add notes | authenticated | true |
248
-
| Creator can delete their own posts | authenticated | ((uid())::text = "userId") |
226
+
## If your token expires in less than 1 hour (3600 seconds in Supabase Dashboard)
249
227
250
-
> Then, go to [http://localhost:3000/rls/notes](http://localhost:3000/rls/notes)
228
+
If you have a lower token lifetime than me (1 hour), you should take a look at `REFRESH_ACCESS_TOKEN_THRESHOLD` in [./app/modules/auth/session.server.ts](./app/modules/auth/session.server.ts) and set what you think is the best value for your use case.
251
229
252
-
## Your token expires in less than 1 hour (3600 seconds in Supabase Dashboard)
230
+
## Supabase RLS
231
+
You may ask "can I use RLS with Remix".
253
232
254
-
If you have a lower token lifetime than me (1 hour), you should take a look at `REFRESH_THRESHOLD` in [./app/modules/auth/const.ts](./app/modules/auth/const.ts) and set what you think is the best value for your use case.
233
+
The answer is "Yes" but It has a cost.
255
234
235
+
Using Supabase SDK server side to query your database (for those using RLS features) adds an extra delay due to calling a Gotrue rest API instead of directly calling the Postgres database (and this is fine because at first Supabase SDK is for those who don't have/want backend).
256
236
237
+
In my benchmark, it makes my pages twice slower. (~+200ms compared to a direct query with Prisma)
0 commit comments