{"id":14968876,"url":"https://github.com/adrianmjim/nestjs-supabase-js","last_synced_at":"2025-10-26T05:30:55.903Z","repository":{"id":223021057,"uuid":"758656161","full_name":"Adrianmjim/nestjs-supabase-js","owner":"Adrianmjim","description":"NestJS Supabase integration","archived":false,"fork":false,"pushed_at":"2024-10-29T08:44:19.000Z","size":273,"stargazers_count":4,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T09:56:34.512Z","etag":null,"topics":["auth","authentication","database","module","nestjs","postgres","storage","supabase","supabase-auth","supabase-db","supabase-js","supabase-realtime","supabase-storage"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Adrianmjim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-16T19:31:52.000Z","updated_at":"2024-10-29T08:43:29.000Z","dependencies_parsed_at":"2024-05-29T21:32:32.234Z","dependency_job_id":"35fe48a9-55c5-4412-9916-b1fa2f0d49ff","html_url":"https://github.com/Adrianmjim/nestjs-supabase-js","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":"0.42500000000000004","last_synced_commit":"c588f662b6acfa70910eb796ed3637fe21b25897"},"previous_names":["adrianmjim/nestjs-supabase","adrianmjim/nestjs-supabase-js"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrianmjim%2Fnestjs-supabase-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrianmjim%2Fnestjs-supabase-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrianmjim%2Fnestjs-supabase-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrianmjim%2Fnestjs-supabase-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adrianmjim","download_url":"https://codeload.github.com/Adrianmjim/nestjs-supabase-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238264711,"owners_count":19443397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","authentication","database","module","nestjs","postgres","storage","supabase","supabase-auth","supabase-db","supabase-js","supabase-realtime","supabase-storage"],"created_at":"2024-09-24T13:40:44.770Z","updated_at":"2025-10-26T05:30:50.607Z","avatar_url":"https://github.com/Adrianmjim.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\" style=\"vertical-align:middle\"\u003e\n  \u003ca href=\"https://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo_text.svg\" width=\"200\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://supabase.com/\" target=\"blank\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/8291514/213727225-56186826-bee8-43b5-9b15-86e839d89393.png#gh-dark-mode-only\" width=\"500\" alt=\"Supabase\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n![Test](https://github.com/adrianmjim/nestjs-supabase-js/actions/workflows/codecov_test.yml/badge.svg)\n[![codecov](https://codecov.io/gh/Adrianmjim/nestjs-supabase-js/graph/badge.svg?token=jNHEDepqm7)](https://codecov.io/gh/Adrianmjim/nestjs-supabase-js)\n[![NPM Version](https://badge.fury.io/js/nestjs-supabase-js.svg?style=flat)](https://npmjs.org/package/nestjs-supabase-js)\n[![NPM Download Stats](https://nodei.co/npm/nestjs-supabase-js.png?downloads=true)](https://www.npmjs.com/package/nestjs-supabase-js)\n\n## Description\n\nThe [Supabase](https://github.com/supabase/supabase-js) module for [NestJS](https://github.com/nestjs/nest).\n\n## Installation\n\nInstall the dependencies via `npm`, `pnpm` or `yarn`:\n\nnpm:\n```bash\n$ npm i -s @nestjs/common @supabase/supabase-js nestjs-supabase-js\n```\n\npnpm:\n```bash\n$ pnpm add @nestjs/common @supabase/supabase-js nestjs-supabase-js\n```\n\nyarn:\n```bash\n$ yarn add @nestjs/common @supabase/supabase-js nestjs-supabase-js\n```\n\n## Configuration\n\nFirst, import the module into your NestJS application and configure it using the configuration key provided by Supabase.\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SupabaseModule } from 'nestjs-supabase-js';\n\n@Module({\n  imports: [\n    SupabaseModule.forRoot({\n      supabaseKey: 'YOUR_SUPABASE_KEY',\n      supabaseUrl: 'YOUR_SUPABASE_URL',\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nOr, You can configure it asynchronously as follows:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SupabaseModule } from 'nestjs-supabase-js';\n\n@Module({\n  imports: [\n    SupabaseModule.forRootAsync({\n      imports: [],\n      inject: [],\n      useFactory: () =\u003e ({\n        supabaseKey: 'YOUR_SUPABASE_KEY',\n        supabaseUrl: 'YOUR_SUPABASE_URL',\n      }),\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n## Multiple connections\n\nIn certain situations, we will need to connect to different Supabase projects, with this module this is possible:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SupabaseModule } from 'nestjs-supabase-js';\n\n@Module({\n  imports: [\n    SupabaseModule.forRoot([\n      {\n        name: 'connection1',\n        supabaseConfig: {\n          supabaseKey: 'YOUR_SUPABASE_KEY',\n          supabaseUrl: 'YOUR_SUPABASE_URL',\n        },\n      },\n      {\n        name: 'connection2',\n        supabaseConfig: {\n          supabaseKey: 'YOUR_SUPABASE_KEY',\n          supabaseUrl: 'YOUR_SUPABASE_URL',\n        },\n      },\n    ]),\n  ],\n})\nexport class AppModule {}\n```\n\nOr asynchronously:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SupabaseModule } from 'nestjs-supabase-js';\n\n@Module({\n  imports: [\n    SupabaseModule.forRootAsync({\n      imports: [],\n      inject: [],\n      useFactory: () =\u003e ([\n        {\n          name: 'connection1',\n          supabaseConfig: {\n            supabaseKey: 'YOUR_SUPABASE_KEY',\n            supabaseUrl: 'YOUR_SUPABASE_URL',\n          },\n        },\n        {\n          name: 'connection2',\n          supabaseConfig: {\n            supabaseKey: 'YOUR_SUPABASE_KEY',\n            supabaseUrl: 'YOUR_SUPABASE_URL',\n          },\n        },\n      ]),\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n## Usage\n\nFirst, inject the client into the module where you want to use it:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SupabaseModule } from 'nestjs-supabase-js';\n\n@Module({\n  imports: [\n    SupabaseModule.injectClient(),\n  ],\n})\nexport class CatModule {}\n```\n\nOr, for a specific connection:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SupabaseModule } from 'nestjs-supabase-js';\n\n@Module({\n  imports: [\n    SupabaseModule.injectClient('connection1', 'connection2'),\n  ],\n})\nexport class CatModule {}\n```\n\nNow you can use the Supabase client in any provider of your module:\n\n```typescript\nimport { SupabaseClient } from '@supabase/supabase-js';\n\nexport class CatService {\n  constructor(private readonly supabaseClient: SupabaseClient) {}\n\n  public doSomething(): void {\n\n  }\n}\n```\n\nOr, for a specific connection:\n\n```typescript\nimport { SupabaseClient } from '@supabase/supabase-js';\nimport { InjectSupabaseClient } from 'nestjs-supabase-js';\n\nexport class CatService {\n  constructor(\n    @InjectSupabaseClient('connection1') private readonly supabaseClient1: SupabaseClient,\n    @InjectSupabaseClient('connection2') private readonly supabaseClient2: SupabaseClient,\n  ) {}\n\n  public doSomething(): void {\n\n  }\n}\n```\n\nIt's also possible to use the InjectSupabaseClient decorator to inject the Supabase client when you don't want to explicitly type it with the client:\n\n```typescript\nimport { SupabaseClient } from '@supabase/supabase-js';\nimport { InjectSupabaseClient } from 'nestjs-supabase-js';\n\nexport class CatService {\n  constructor(\n    @InjectSupabaseClient() private readonly supabaseClient: unknown,\n  ) {}\n\n  public doSomething(): void {\n\n  }\n}\n```\n\n## Authentication\n\nThis library provides a base guard to authenticate requests using the Supabase auth client.\n\n### Usage\n\nTo create your own guard that authenticates against Supabase, you just need to create a new guard that extends `BaseSupabaseAuthGuard` and implements the method `extractTokenFromRequest`. This implementation should define how to extract the token from the request, which might be in the headers, cookies, or query parameters.\n\n```typescript\nimport { Injectable, ExecutionContext } from '@nestjs/common';\nimport { SupabaseClient } from '@supabase/supabase-js';\nimport { BaseSupabaseAuthGuard } from 'nestjs-supabase-js';\n\n@Injectable()\nexport class MyAuthGuard extends BaseSupabaseAuthGuard {\n  public constructor(supabaseClient: SupabaseClient) {\n    super(supabaseClient);\n  }\n\n  protected extractTokenFromRequest(request: Request): string | undefined {\n    return request.headers.authorization;\n  }\n}\n```\n\nThen, you can bind the guard as described in the [NestJS documentation](https://docs.nestjs.com/guards#binding-guards).\n\n## 🤝 Contributing [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/adrianmjim/nestjs-supabase-js/issues)\n\nContributions, issues and feature requests are welcome.\n\n## Authors\n\n👤 **Adrián Martínez Jiménez**\n\n- Github: [@adrianmjim](https://github.com/adrianmjim)\n\nSee also the list of contributors who [participated](https://github.com/adrianmjim/nestjs-supabase-js/contributors) in this project.\n\n## Show Your Support\n\nPlease ⭐️ this repository if this project helped you!\n\n## 📝 License\n\nCopyright © 2024 [Adrián Martínez Jiménez](https://github.com/adrianmjim).\n\nThis project is licensed under the MIT License - see the [LICENSE file](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmjim%2Fnestjs-supabase-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrianmjim%2Fnestjs-supabase-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmjim%2Fnestjs-supabase-js/lists"}