{"id":14971467,"url":"https://github.com/coopflow/fastify-supabase","last_synced_at":"2025-10-26T15:30:41.272Z","repository":{"id":37086118,"uuid":"410903687","full_name":"coopflow/fastify-supabase","owner":"coopflow","description":"Supabase client initialization and encapsulation in fastify framework","archived":false,"fork":false,"pushed_at":"2023-03-28T15:00:42.000Z","size":43,"stargazers_count":30,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T20:55:57.273Z","etag":null,"topics":["fastify","fastify-plugin","fastify-supabase","supabase"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/coopflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-27T13:50:44.000Z","updated_at":"2024-11-18T16:24:09.000Z","dependencies_parsed_at":"2023-02-12T23:45:21.444Z","dependency_job_id":null,"html_url":"https://github.com/coopflow/fastify-supabase","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coopflow%2Ffastify-supabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coopflow%2Ffastify-supabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coopflow%2Ffastify-supabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coopflow%2Ffastify-supabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coopflow","download_url":"https://codeload.github.com/coopflow/fastify-supabase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238357362,"owners_count":19458560,"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":["fastify","fastify-plugin","fastify-supabase","supabase"],"created_at":"2024-09-24T13:45:14.900Z","updated_at":"2025-10-26T15:30:40.847Z","avatar_url":"https://github.com/coopflow.png","language":"JavaScript","readme":"# fastify-supabase\n\n[![NPM version](https://img.shields.io/npm/v/fastify-supabase.svg?style=flat)](https://www.npmjs.com/package/fastify-supabase)\n[![GitHub CI](https://github.com/coopflow/fastify-supabase/workflows/GitHub%20CI/badge.svg)](https://github.com/coopflow/fastify-supabase/actions?workflow=GitHub+CI)\n[![Coverage Status](https://coveralls.io/repos/github/coopflow/fastify-supabase/badge.svg?branch=main)](https://coveralls.io/github/coopflow/fastify-supabase?branch=main)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n\n[Supabase client](https://github.com/supabase/supabase-js) initialization and encapsulation in [fastify](https://github.com/fastify/fastify) framework.\n\n## Install\n\nInstall the package with:\n```sh\nnpm i fastify-supabase --save\n```\n\n\n## Usage\n\nThe package needs to be added to your project with `register` and you must at least configure your Supabase API key and your Supabase URL wich are available in your Supabase project settings then call the Supabase API and you are done.\n```js\nconst fastify = require('fastify')({ logger: true })\n\nfastify.register(require('fastify-supabase'), {\n  supabaseKey: 'public-anon-key',\n  supabaseUrl: 'https://xyzcompany.supabase.co'\n})\n\nfastify.get('/read', async (request, reply) =\u003e {\n  const { supabase } = fastify\n\n  const { data, error } = await supabase.from('cities').select()\n\n  return { data, error }\n})\n\nfastify.listen(3000, (err) =\u003e {\n  if (err) {\n    fastify.log.error(err)\n    process.exit(1)\n  }\n})\n```\n\n### Options\n\n* `supabaseKey` **[ required ]** `\u003cstring\u003e`: The unique Supabase Key which is supplied when you create a new project in your project dashboard.\n\n* `supabaseUrl` **[ required ]** `\u003cstring\u003e`: The unique Supabase URL which is supplied when you create a new project in your project dashboard.\n\n* `namespace` **[ optional ]** `\u003cstring\u003e`: Through this option `fastify-supabase` lets you define multiple Supabase singular instances (with different options parameters if you wish) that you can later use in your application.\n```js\nconst fastify = require('fastify')({ logger: true })\n\nfastify.register(require('fastify-supabase'), {\n  namespace: 'one',\n  supabaseKey: 'public-anon-key-one',\n  supabaseUrl: 'https://xyzcompanyprojectone.supabase.co'\n})\n\nfastify.register(require('fastify-supabase'), {\n  namespace: 'two',\n  supabaseKey: 'public-anon-key-two',\n  supabaseUrl: 'https://xyzcompanyprojecttwo.supabase.co'\n})\n\nfastify.get('/fetch-from-one', async (request, reply) =\u003e {\n  const { supabase } = fastify\n\n  const { data, error } = await supabase.one.from('project_one_table').select()\n\n  return { data, error }\n})\n\nfastify.get('/fetch-from-two', async (request, reply) =\u003e {\n  const { supabase } = fastify\n\n  const { data, error } = await supabase.two.from('project_two_table').select()\n\n  return { data, error }\n})\n\nfastify.listen(3000, (err) =\u003e {\n  if (err) {\n    fastify.log.error(err)\n    process.exit(1)\n  }\n})\n```\n\n* `schema` **[ optional ]** `\u003cstring\u003e`: The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to 'public'.\n\n* `headers` **[ optional ]** `\u003c{ [key: string]: string }\u003e`: Optional headers for initializing the client.\n\n* `autoRefreshToken` **[ optional ]** `\u003cboolean\u003e`: Automatically refreshes the token for logged in users.\n\n* `persistSession` **[ optional ]** `\u003cboolean\u003e`: Whether to persist a logged in session to storage.\n\n* `detectSessionInUrl` **[ optional ]** `\u003cboolean\u003e`: Detect a session from the URL. Used for OAuth login callbacks.\n\n* `localStorage` **[ optional ]** `\u003cSupabaseAuthClientOptions['localStorage']\u003e`: A storage provider. Used to store the logged in session.\n\n* `realtime` **[ optional ]** `\u003cRealtimeClientOptions\u003e`: Options passed to the realtime-js instance.\n\n*__Note for TypeScript users__: If you are a TypeScript user, take a look at [Supabase Generating Types documentation](https://supabase.io/docs/reference/javascript/generating-types).*\n\n## Documentation\n\nSee the [Supabase reference documentation](https://supabase.io/docs/reference/javascript/supabase-client).\n\n## Testing\n\n- Create a test table in your [Supabase](https://app.supabase.io) project database with:\n```SQL\nCREATE TABLE \"public\".\"fastify_supabase_test\" (\n  \"id\" uuid DEFAULT GEN_RANDOM_UUID() NOT NULL,\n  \"job\" uuid NOT NULL,\n  \"name\" character varying NOT NULL,\n  \"created_at\" timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,\n  CONSTRAINT \"fastify_supabase_test_id__pkey\" PRIMARY KEY (\"id\")\n) WITH (oids = false);\n```\n- Create a file named `.env` (at the root of this project) providing your `supabaseKey` and `supabaseUrl`:\n```sh\nSUPABASE_API_KEY=public-anon-key-of-your-project\nSUPABASE_PROJECT_URL=https://xyzcompany.supabase.co\n```\n- Finally run tests with:\n```sh\nnpm run test\n```\n\n## Acknowledgements\n\n- [Ruan Martinelli](https://ruanmartinelli.com/) for kindly transferring the ownership of the package name.\n- This project is kindly sponsored by [coopflow](https://www.coopflow.com).\n\n\n## License\n\nLicensed under [MIT](https://github.com/coopflow/fastify-supabase/blob/main/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoopflow%2Ffastify-supabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoopflow%2Ffastify-supabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoopflow%2Ffastify-supabase/lists"}