Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change Site Theme
Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Agent Actions
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates
Developer guides
Overview

  • Develop with AI

    Best practices

  • Query optimization

    Paginating with GROQ
    High performance GROQ

  • Roles and authentication

    Setting up Single Sign-On with SAML
    Third-Party Login (Deprecated)
    OAuth2
    Set up SSO authentication with SAML and Azure/Entra ID
    Set up SSO authentication with SAML and PingIdentity
    Set up SSO authentication with SAML and JumpCloud
    Reconcile users against internal systems
    Restrict Access to Specific Documents
    Setting up a Default Relay State for IdP Initiated - SAML Logins

  • Structured content

    Scalable navigation patterns
    An opinionated guide to Sanity Studio
    Browsing Content How You Want with Structure Builder
    Deciding on fields and relationships
    Create richer array item previews
    Dynamic folder structure using the currentUser and workflow states
    Create a time duration object field
    Level up Your Edit Modal with Next/Previous Navigation Buttons for Array Items
    Create a “coupon generator” string field input
    Managing redirects with Sanity
    Create a document form progress component
    Create an array input field with selectable templates
    Creating a Parent/Child Taxonomy
    Create interactive array items for featured elements
    Create a visual string selector field input
    Create a survey rating number field input
    How to use structured content for page building
    Create a recycling bin for deleted documents via Sanity Functions

  • Frontend integration

    Add live content to your application
    Forms with Sanity
    Vercel Integration
    Build your blog with Astro and Sanity
    How to implement front-end search with Sanity

  • Ecommerce

    Displaying Sanity content in Shopify
    Sanity Connect for Shopify
    Custom sync handlers for Sanity Connect

  • Integrating with other services

    A/B testing with Sanity and Growthbook
    Cookie consent integrations with Sanity
    Integrating external data sources with Sanity
    Klaviyo (email campaigns)
    Developing with Next.js on GitHub Codespaces

  • Adopting Sanity

    How to pitch Sanity.io to your team
    Convincing your clients to go with Sanity.io, rather than a traditional CMS
    Not-profit plan
    Agencies: Navigating the Spring 2025 Organization Changes
    How to generate massive amounts of demo content for Sanity
    How to implement Multi-tenancy with Sanity

  • GROQ

    GROQ-Powered Webhooks – Intro to Filters
    GROQ-Powered Webhooks – Intro to Projections

  • Portable Text

    Presenting Portable Text
    Add Inline blocks for the Portable Text Editor
    Beginners guide to Portable Text
    How to add custom YouTube blocks to Portable Text
    Converting Inline Styles to Sanity Block Decorators
    Add things to Portable Text
    Change the height of the PTE

  • Community and ecosystem

    Create your own Sanity template
    Community guides
    Community Code of Conduct
    Contribute to the ecosystem

  • Plugin development

    Migrating plugins to support Content Releases

On this page

Previous

Forms with Sanity

Next

Build your blog with Astro and Sanity

Was this page helpful?

On this page

  • Installation
  • Usage
  • Accessing environment variables
  • Troubleshooting
  • Select an authentication method in CLI or Studio
  • Missing projects or data after signing in
  • Limitations
Developer guidesLast updated February 5, 2026

Vercel Integration

How to install and use the Sanity's official Vercel integration

Sanity’s Vercel integration lets you connect your Vercel and Sanity projects. The Integration lets you manage features like billing and plan management directly in Vercel.

The integration adds environment variables to your Vercel project(s) with the Project ID, a given dataset name, and an editor token with read+write permissions. You can use these environment variables to connect your project on Vercel to Sanity’s Content Lake and fetch, create, and update data in it.

Installation

Go to Vercel's integrations marketplace and follow the instructions.

We recommend you to choose the Native Integration option as this lets you to have a deeper integration with Vercel’s ecosystem.

Select Install and follow the steps to set up the connection. These are a few key decisions you need to make:

  • Specify a prefix for your environment variables: This guide uses the default, NEXT_PUBLIC in the examples below.
  • Select a plan: we offer Free and Growth self-serve options through Vercel at this time. To sign up for an Enterprise plan, contact sales.
  • Select a project name, or use the default suggested one.

Once the installation completes, follow the getting started guide for your framework of choice.

Usage

This integration adds your project information as environment variables. You can go to Vercel's documentation to learn more about how to use and configure them.

The project ID will be exposed by the following environment variables in your Vercel project.

  • SANITY_API_PROJECT_ID
  • SANITY_STUDIO_API_PROJECT_ID
  • NEXT_PUBLIC_SANITY_PROJECT_ID

Project IDs are considered public.

The dataset will be exposed by the following environment variables in your Vercel project.

  • SANITY_API_DATASET
  • NEXT_PUBLIC_SANITY_DATASET
  • SANITY_STUDIO_API_DATASET

Dataset names are considered public.

The write token will be exposed on the following environment variables in your Vercel project:

  • SANITY_API_WRITE_TOKEN

Since write tokens give access to changing data in your dataset, they should be considered secret.

Accessing environment variables

Here is an example of a serverless function that can be run on Vercel that will take a request with some data, and create a new document of that data in the Sanity Content Lake:

const {createClient} = require('@sanity/client');

const config = {
  projectId: process.env.SANITY_API_PROJECT_ID,
  dataset: process.env.SANITY_API_DATASET,
  token: process.env.SANITY_API_WRITE_TOKEN,
  useCdn: false,
  apiVersion: '2021-03-25'
};

async function handleForm(req, res) {
  const payload = JSON.parse(req.body);
  try {
    const result = await createClient(config).create(payload);
    return res.status(200).send('ok');
  } catch (error) {
    return res.status(500)send('error');
  }
}

export default handleForm;

Troubleshooting

Select an authentication method in CLI or Studio

When you sign in to your studio, or when the CLI prompts you to authenticate, select the sign-in method that matches your Sanity account configuration:

  • If you connected a sign-in method earlier: During the Getting Started guide, if you selected "Open in Sanity" on the integration Dashboard and linked a sign-in method in Account Settings, use that same method (GitHub or Google).
  • If you skipped that step: Use GitHub or Google to login with the same email address you use for Vercel.
  • If neither applies: Open the Sanity management interface from the Vercel integration Dashboard, navigate to Account Settings, and add a sign-in method to your account.

Missing projects or data after signing in

If you've signed in to Sanity but don't see the projects or data you expect, you may have multiple accounts.

For existing Sanity users

If you used Sanity before the Vercel integration, you likely already had an account. During integration provisioning, a new account may have been created. To resolve this:

  • Add another sign-in method to consolidate your accounts in Account Settings.
  • Sign out of both the CLI and Sanity.
  • Continue with the Getting Started guide using your original account credentials.

For new Sanity users

You may have accidentally created a separate account. You have two options:

  • Keep the account: Log out of both Sanity and the CLI, then continue with the Getting Started guide.
  • Delete the account: Verify this is an unused account before proceeding. Deleted accounts cannot be recovered.

Before continuing with the Getting Started guide, add another sign-in method in Account Settings to ensure seamless access between sign-in methods.

Limitations

Projects set up via the Vercel integration need to be managed through the integration dashboard in Vercel.

Deleting a project via Sanity management interface is not supported. Plan changes need to happen through the integration Dashboard in Vercel.

const {createClient} = require('@sanity/client');

const config = {
  projectId: process.env.SANITY_API_PROJECT_ID,
  dataset: process.env.SANITY_API_DATASET,
  token: process.env.SANITY_API_WRITE_TOKEN,
  useCdn: false,
  apiVersion: '2021-03-25'
};

async function handleForm(req, res) {
  const payload = JSON.parse(req.body);
  try {
    const result = await createClient(config).create(payload);
    return res.status(200).send('ok');
  } catch (error) {
    return res.status(500)send('error');
  }
}

export default handleForm;