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
SupabaseInstancefor 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_GUARDfor global Auth guarding or useUseGuard()per route - use
supabase.getClient()that will create you a "per request client" withScope.REQUESToption - 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_tokenas your Bearer Authorization - start application*
- make GET / request
$ npm run start