mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
153 lines
9.7 KiB
Plaintext
153 lines
9.7 KiB
Plaintext
---
|
|
id: 'vercel-marketplace'
|
|
title: 'Vercel Marketplace'
|
|
description: 'Manage your Supabase projects directly through Vercel'
|
|
---
|
|
|
|
## Overview
|
|
|
|
The Vercel Marketplace lets you create and manage third-party resources, such as Supabase, from the Vercel platform. Through the Marketplace, Vercel bills you for your Supabase usage, and you sign in to Supabase with your Vercel account. Your Vercel team roles also carry over to your Supabase organization.
|
|
|
|
When you create an organization and projects through the Vercel Marketplace, they function like those created directly within Supabase. However, the billing is handled through your Vercel account, and you can manage your resources directly from the Vercel dashboard or CLI. The integration also syncs environment variables to your connected Vercel projects.
|
|
|
|
When you connect a Vercel project, Supabase turns on SSL enforcement and database token access for the Supabase project. Your Vercel deployments can then [connect with a Vercel-issued token](#connect-with-database-token-access) instead of the database password.
|
|
|
|
For more information, see the [Introducing the Vercel Marketplace](https://vercel.com/blog/introducing-the-vercel-marketplace) blog post.
|
|
|
|
To keep Vercel preview deployments off your production database, see [Preview branches on Vercel](/docs/guides/integrations/vercel-preview-branches).
|
|
|
|
## Quickstart
|
|
|
|
Set up Supabase on Vercel in one of two ways: deploy a starter template, or install Supabase from the Vercel Marketplace. Both create a Supabase project and sync the following environment variables to your connected Vercel projects:
|
|
|
|
```
|
|
POSTGRES_URL
|
|
POSTGRES_PRISMA_URL
|
|
POSTGRES_URL_NON_POOLING
|
|
POSTGRES_USER
|
|
POSTGRES_HOST
|
|
POSTGRES_POOLER_HOST
|
|
POSTGRES_PASSWORD
|
|
POSTGRES_DATABASE
|
|
SUPABASE_SECRET_KEY
|
|
SUPABASE_PUBLISHABLE_KEY
|
|
SUPABASE_URL
|
|
SUPABASE_PROJECT_REF
|
|
SUPABASE_JWT_SECRET
|
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
|
NEXT_PUBLIC_SUPABASE_URL
|
|
```
|
|
|
|
Your app uses these variables to connect to your database and Supabase APIs.
|
|
|
|
### Via template
|
|
|
|
<div className="bg-surface-100 py-4 px-5 border rounded-md not-prose">
|
|
<h4 className="text-foreground">Deploy a Next.js app with Supabase</h4>
|
|
<p className="text-foreground-light mb-3">Uses the Next.js Supabase starter template</p>
|
|
<a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&project-name=nextjs-with-supabase&repository-name=nextjs-with-supabase&stores=%5B%7B%22type%22%3A%22integration%22%2C%22integrationSlug%22%3A%22supabase%22%2C%22productSlug%22%3A%22supabase%22%7D%5D">
|
|
<img src="https://vercel.com/button" alt="Deploy with Vercel" />
|
|
</a>
|
|
</div>
|
|
|
|
### Via Vercel Marketplace
|
|
|
|
In the Vercel Marketplace, go to the [Supabase page](https://vercel.com/marketplace/supabase) and click **Install**.
|
|
|
|
## Connect with database token access
|
|
|
|
Your Vercel functions can connect to the database through [database token access](/docs/guides/platform/database-token-access) with a short-lived token that Vercel mints for the Supabase resource instead of the database password.
|
|
|
|
A Vercel function gets that token in two steps:
|
|
|
|
1. Read the deployment's own OIDC token from the `x-vercel-oidc-token` request header. Outside a request, call `getVercelOidcToken()` from `@vercel/functions/oidc`.
|
|
2. Exchange it for a resource token for the role you connect as. The resource ID is your main Supabase project's ref, even for preview deployments. Set `role` to `postgres` or `supabase_read_only_user`:
|
|
|
|
```js
|
|
import { getVercelOidcToken } from '@vercel/functions/oidc'
|
|
|
|
// Your main Supabase project's ref. In a preview deployment, SUPABASE_PROJECT_REF is set to the
|
|
// preview branch's ref instead.
|
|
const MAIN_PROJECT_REF = 'YOUR_MAIN_PROJECT_REF'
|
|
|
|
async function getSupabaseDatabaseToken(role = 'postgres') {
|
|
const oidcToken = await getVercelOidcToken()
|
|
const response = await fetch(
|
|
`https://api.vercel.com/v1/integrations/resources/${MAIN_PROJECT_REF}/token?role=${role}`,
|
|
{ method: 'POST', headers: { Authorization: `Bearer ${oidcToken}` } }
|
|
)
|
|
if (!response.ok) throw new Error(`Token request failed: ${response.status}`)
|
|
return (await response.json()).token
|
|
}
|
|
```
|
|
|
|
Each token connects only as the role it was minted for. If you leave out `role`, Vercel mints a `service_role` token that works with the Data API but can't connect to the database. Because tokens last up to 15 minutes, request a new one shortly before the current one expires. For local development, run `vercel link` and `vercel env pull` to get a development OIDC token.
|
|
|
|
Build the connection string from the environment variables the integration syncs and use the token as the password:
|
|
|
|
| Connection | Connection string |
|
|
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| Shared pooler, transaction mode | `postgres://postgres.${SUPABASE_PROJECT_REF}:YOUR_TOKEN@${POSTGRES_POOLER_HOST}:6543/${POSTGRES_DATABASE}?sslmode=require&options=-c%20jit%3Dtrue` |
|
|
| Shared pooler, session mode | Same as transaction mode on port `5432` |
|
|
| Prisma | Transaction mode with `&pgbouncer=true` added |
|
|
| Read-only, shared pooler | Same as transaction mode with the user `supabase_read_only_user.${SUPABASE_PROJECT_REF}` |
|
|
| Direct connection | `postgres://${POSTGRES_USER}:YOUR_TOKEN@${POSTGRES_HOST}:5432/${POSTGRES_DATABASE}?sslmode=require` |
|
|
|
|
Shared pooler connections need `jit=true` as shown in the table above. A token from a production deployment reaches the main project whereas a token from a preview deployment reaches that deployment's preview branch.
|
|
|
|
The `@vercel/postgres` package doesn't work with these tokens because it accepts only its own pooled connection URLs. Connect with another Postgres client instead.
|
|
|
|
## Studio support
|
|
|
|
To open Supabase Studio from the Vercel dashboard, start from either of the following tabs. Each one opens a different page in Supabase:
|
|
|
|
- **Integrations** tab: Next to Supabase, click **Manage**, then click **Open in Supabase**. The Supabase Dashboard homepage opens.
|
|
- **Storage** tab: Select your Supabase project, then click **Open in Supabase**. That project opens in the Supabase Dashboard.
|
|
|
|
Supabase Studio provides tools such as:
|
|
|
|
- **SQL Editor**: Run SQL queries against your database.
|
|
- **Table Editor**: Create, edit, and delete tables and columns.
|
|
- **Log Explorer**: Inspect real-time logs for your database.
|
|
- **Postgres Upgrades**: Upgrade the Postgres version of your database.
|
|
- **Compute Upgrades**: Scale the compute resources allocated to your database.
|
|
|
|
## How your Vercel team maps to Supabase
|
|
|
|
There is a direct one-to-one relationship between a Supabase organization and a Vercel team. Installing the integration or launching your first Supabase project through Vercel triggers the creation of a corresponding Supabase organization if one doesn't already exist.
|
|
|
|
When Vercel users interact with Supabase, they are automatically assigned Supabase accounts. New users get a Supabase account linked to their primary email, while existing users have their Vercel and Supabase accounts linked.
|
|
|
|
- The user who creates the [Supabase database](/docs/guides/database/overview) from the Vercel dashboard is assigned the `owner` role in the new Supabase organization.
|
|
- Subsequent users are assigned roles based on their Vercel role, such as `developer` for `member` and `owner` for `owner`.
|
|
|
|
Role management is handled directly in the Vercel dashboard, and changes are synchronized with Supabase.
|
|
|
|
<Admonition type="note">
|
|
|
|
Permissions for users who aren't on your Vercel team don't sync with Vercel. You can still invite them to your Supabase organization.
|
|
|
|
</Admonition>
|
|
|
|
## Pricing
|
|
|
|
Pricing for databases created through the Vercel Marketplace is identical to pricing for databases created directly in Supabase. For more information, see [Supabase pricing](/pricing).
|
|
|
|
The [usage page](/dashboard/org/_/usage) tracks the usage of your Vercel databases, with this information sent to Vercel for billing, which appears on your Vercel invoice.
|
|
|
|
<Admonition type="caution">
|
|
|
|
Changing your plan resets your Supabase billing cycle to start on the day of the change. Your Supabase organization's billing cycle is separate from Vercel's, and the first cycle starts on the day you install the integration.
|
|
|
|
</Admonition>
|
|
|
|
## Limitations
|
|
|
|
When you use the Vercel Marketplace, the following limitations apply:
|
|
|
|
- Projects can only be created from the Vercel dashboard. To create one, see [Quickstart](#quickstart).
|
|
- Organizations are removed only when you [delete all their projects](/kb/troubleshooting/how-to-delete-vercel-linked-projects-9d08aa) and then uninstall the Vercel Marketplace integration.
|
|
- Owners can't be added in the Supabase Dashboard. To make someone an owner, give them the `owner` role on your Vercel team. For how roles map between Vercel and Supabase, see [How your Vercel team maps to Supabase](#how-your-vercel-team-maps-to-supabase).
|
|
- Invoices and payments are managed in the Vercel dashboard, not in the Supabase Dashboard. For how your Supabase usage reaches your Vercel invoice, see [Pricing](#pricing).
|
|
- [Custom domains](/docs/guides/platform/custom-domains) aren't supported. The Vercel environment variables always use your project's base `SUPABASE_URL`.
|