This is an example for Supabase v1. The API has changed in later versions, but the most important idea here - use NestJS's Services with the correct scope to have a separate
SupabaseInstance
for different requests https://docs.nestjs.com/fundamentals/injection-scopes
This is an example of how to setup and use Supabase with Nest.js: Auth and Client. Follow the article for more info.
Using in your app:
- copy supabase folder
- import SupabaseModule where you need
- add
APP_GUARD
for global Auth guarding or useUseGuard()
per route - use
supabase.getClient()
that will create you a "per request client" withScope.REQUEST
option - this is essential, such as we cannotsetAuth()
like on the client-side once
$ npm install
- add valid .env file from your Supabase
- get user's
access_token
- update code in AppService that matches your business logic / table name / etc.
- use
access_token
as your Bearer Authorization - start application*
- make GET / request
$ npm run start