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
    • 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
Functions
Overview

  • Introduction
  • Get started

    Create a Document Function
    Create a Media Library Asset Function
    Official recipes

  • Concepts

    Manage dependencies
    Local testing

  • Guides

    Configure @sanity/client
    Add environment variables
    Common patterns

  • Reference

    Handler reference
    CLI reference

FunctionsLast updated January 29, 2026

Deploy custom functions to automate content operations

Sanity Functions enable you to execute custom logic whenever changes occur in your content—all without requiring your own infrastructure.

Create your first function

Create a Document Function

Start building with Functions by deploying a new function to Sanity's infrastructure.

Create a Media Library Asset Function

Start building a function that reacts to changes to a Media Library asset.

Official recipes

Get started with pre-built functions for popular use cases

Core concepts and guides

Introduction

Learn how to take advantage of Functions in your Sanity projects.

Testing functions locally

Simulate Functions locally with real data and an interactive playground.

Configure @sanity/client in Functions

Learn to use the JavaScript client in a Sanity Function.

Add environment variables to functions

Learn to add environment variables to Functions.

Functions cheat sheet

Common patterns and techniques for creating Functions.