A convenience wrapper for the Supabase Management API written in TypeScript.
The Management API is in beta. It is usable in it's current state, but it's likely that there will be breaking changes.
To install supabase-management-js in a Node.js project:
npm install supabase-management-jssupabase-management-js requires Node.js 18 and above because it relies on the native fetch client.
The recommended way to use the SDK is through the SupabaseManagementAPI class. It handles authentication automatically, so you only need to pass your access token — retrieved either through OAuth or by generating an API token in your account page — once at construction time. Your API tokens carry the same privileges as your user account, so be sure to keep them secret.
import { SupabaseManagementAPI } from "supabase-management-js"; const api = new SupabaseManagementAPI({ accessToken: "<access token>" }); const response = await api.listAllProjects(); if (response.status === 200) { console.log(`Found ${response.data.length} projects`); }By default the client targets https://api.supabase.com. Pass a baseUrl option to the constructor to point the client at a different endpoint, such as a staging environment or a local proxy:
const api = new SupabaseManagementAPI({ accessToken: "<access token>", baseUrl: "https://api.staging.supabase.com", });Every method returns a Promise that resolves to a discriminated union of { data, status, headers }. Narrow on status to handle errors without try/catch:
const response = await api.getProject("my-project-ref"); if (response.status === 200) { console.log(response.data.name); } else { // response.data and response.status are narrowed to the error variant console.error(`Error: HTTP ${response.status}`); }Each endpoint is also exported as a standalone async function for cases where you prefer not to use the class. Pass your access token via a RequestInit options object:
import { v1ListAllProjects } from "supabase-management-js"; const response = await v1ListAllProjects({ headers: { Authorization: `Bearer <access token>` }, });Contributions to this project are very welcome and greatly appreciated!
-
Clone the repo into a public GitHub repo (or fork https://github.com/supabase-community/supabase-management-js/fork).
-
Go to the project folder.
cd supabase-management-js- Install packages with
npm:
npm install-
Make your changes
-
Make sure types are correct
npm run typecheck- Create a changeset to describe your changes if you are making changes to the source code that affects its public API
npm exec changeset- Create a branch, commit your changes, and open a Pull Request against the
mainbranch in this repo.
This project uses Changesets for automated versioning and publishing.
- Create a changeset by running:
npm exec changesetThis command will prompt you to:
- Select which package version to bump (
patch,minor, ormajor) - Describe your changes (this becomes part of the release notes)
Once accepted it will create a changeset file inside the .changeset folder which can be updated with your release notes. Changesets support Markdown formatting, so you can include bullet points, links, and other formatting in your release notes.
- Commit the changeset file and merge the PR.
After your PR is merged the release.yml workflow will create another PR that bumps the version and updates CHANGELOG.md with all pending changeset descriptions.
- Merge the second PR.
After this second PR is merged, the release.yml workflow will build and publishe the new version to npm, and create a GitHub release with the changelog.
The files under src/generated/ are auto-generated from the Supabase OpenAPI spec using orval. To refresh both the spec and the generated client in one step, run:
npm run generateThis will regenerate the code based on what the latest Supabase Management OpenAPI spec is.