惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 聂微东
IT之家
IT之家
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
博客园 - 【当耐特】
The Cloudflare Blog
宝玉的分享
宝玉的分享
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
Visual Studio Blog
小众软件
小众软件
博客园_首页
Last Week in AI
Last Week in AI
J
Java Code Geeks
V
V2EX
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
博客园 - 司徒正美
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
The Register - Security
The Register - Security
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
N
Netflix TechBlog - Medium
F
Full Disclosure
B
Blog
H
Help Net Security
C
Check Point Blog
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
P
Proofpoint News Feed
D
Docker
Microsoft Security Blog
Microsoft Security Blog

Sanity.io

A Board Game agent built using Sanity Context and Vercel's AI SDK | Sanity Build a prototype with Claude Code that your whole team can edit | Sanity What’s New - May 2026 | Sanity I built a London pub guide with v0 and the Sanity MCP in six hours. Here's what I learned. | Sanity Build a conference concierge with Agent Context and Anthropic | Sanity Build a content-aware Telegram agent with Vercel AI SDK and Chat SDK | Sanity How I used Agent API to generate photos for my family’s recipes | Sanity What’s New April - 2026 | Sanity Better context, better matches: An AI love story (for dogs) | Sanity How to write for an agent | Sanity Content Agent, meet Slack: AI content operations in your workflow | Sanity Structure powers intelligence | Sanity Your agent needs better content. Here's how to give it. | Sanity How to serve content to agents (a field guide) | Sanity Sanity TypeGen GA: Automatic TypeScript types for content and GROQ | Sanity Sanity is now available on the Vercel Marketplace | Sanity The logo soup problem (and how to solve it) | Sanity Content Releases: From scattered updates to coordinated publishing | Sanity What's New - February 2026 | Sanity How we solved the agent memory problem | Sanity v0 Builder Challenge: The winners | Sanity Introducing: Sanity Agent Skills | Sanity Content Agent: Days of work in one conversation | Sanity Our Sanity Values | Sanity Open Source Pledge 2025: Stepping up when it matters | Sanity v0 builder challenge: $3000 in prizes | Sanity Why AI Breaks Without Structured Content Operations | Sanity What’s New January - 2026 | Sanity BFCM 2025: What teams built when infrastructure stopped being the problem | Sanity How AI shaped holiday shopping and what it means for content in 2026 | Sanity Sanity Studio v5: Embracing React 19 | Sanity You’ll need a CMS eventually. Let your agent set it up. | Sanity “You should never build a CMS” | Sanity AI Content Operations: A 30-Day Implementation Guide | Sanity What’s New December - 2025 | Sanity Scheduled Drafts: Stop manually publishing content at midnight | Sanity What’s New November - 2025 | Sanity Everything *[NYC] 2025 recap: A day of AI, Content Operations, and Culture | Sanity Clankers and content operations | Sanity Content Agent: AI that understands your structured content is here | Sanity Why design-driven content modeling creates technical debt, not velocity | Sanity What's New October - 2025 | Sanity From studio to inbox: How Kevin Green eliminated email campaign friction | Sanity The content editor's guide to content operations [E-commerce edition] | Sanity styled-components maintenance mode: A 40% faster fork | Sanity From zero code to a live website in 7 hours (thanks, Cursor!) | Sanity First attempt will be 95% garbage: A staff engineer's 6-week journey with Claude Code | Sanity Internationalization is more than translating words | Sanity What's New - September 2025 | Sanity We just deleted our 35k-member community Slack | Sanity What's New - August 2025 | Sanity The engineer's guide to content operations [E-commerce edition] | Sanity SEO for AI: Evolving from Web Pages to the Content Lake | Sanity What's New - July 2025 | Sanity Sanity Studio v4: A major version bump for a minor reason | Sanity What's New - June 2025 | Sanity Dashboard and Insights: Your New Content HQ | Sanity Canvas: AI-accelerated, context-aware, freeform authoring | Sanity Agent Actions: AI building blocks for structured content | Sanity A new era for content applications with Sanity App SDK | Sanity The end of CMS era and our $85M Series C. | Sanity What's New – May 2025 | Sanity Introducing the Sanity Model Context Protocol (MCP) server | Sanity What's New – April 2025 | Sanity Pushing all the envelopes with ambitious content | Sanity Self-hosting is only free if your time is worth nothing | Sanity Content that lasts: Scaling beyond your frontend | Sanity The Live Content API is now Generally Available | Sanity The future beyond AI chat bots | Sanity Learning the new skill of working with AI | Sanity What's New - March 2025 | Sanity Give it in plain text: Making your content AI-Ready | Sanity No More 'DO NOT PUBLISH': Introducing Content Releases | Sanity React in 2025, what's next? | Sanity The final boss of front-end: block editors | Sanity Introducing Sanity for Startups | Sanity A block content editor that loves you back | Sanity A Black Friday Snooze Fest: Massive Traffic, No Drama | Sanity How to make a recipe site that scales well | Sanity The Sanity Winter Release 2024 | Sanity AVIF Arrives, Sanity’s Promise Fulfilled | Sanity Sanity joins the Open Source Pledge | Sanity Your content is now Live by default | Sanity Begin Team to Join Sanity | Sanity Sanity Digest - September '24 Edition | Sanity Sanity partners with Google. Now live on the Google Cloud Marketplace. | Sanity Sanity Digest - August ‘24 Edition | Sanity Now playing: the latest Mux Video Input plugin for Sanity | Sanity Community Digest - June ‘24 Edition | Sanity Community Digest - May ‘24 Edition | Sanity Guide to Sanity's newest product announcements | Sanity AI and Content Creation: A Leader's Guide | Sanity Of course, you should be able to type your content quickly! | Sanity New to AI Assist: translation, reference suggestions, image generation | Sanity Speak the language of your editors: Sanity Studio UI localization | Sanity Introducing the new Sanity Growth plan to serve collaborative teams | Sanity Presentation: Work faster than ever with structured content | Sanity Goodbye Feedback Frenzy, Hello Sanity Studio Comments! | Sanity Easing into the App Router with the Sanity Toolkit for Next.js | Sanity Making website updates easier with structured content | Sanity
Functions: Life beyond pressing publish | Sanity
Simeon Griggs · 2025-05-15 · via Sanity.io

Sanity Functions is a fully managed serverless environment that lets you create custom content workflows without managing infrastructure.

Automate events that react to content changes. You may validate content, trigger external services, or transform content with AI Agent Actions—all while Sanity handles the scaling, security, and reliability.

Functions integrate seamlessly with your content operations, letting you focus on building what matters to your authors and business.

For everything that happens next

Content is never truly finished, and its life cycle doesn't end when you paste it into a browser and press publish. It may need to be translated to appear in other markets, update a search index, or revalidate a cache to appear on a website at all. These actions directly respond to pressing publish and are the next step in any content lifecycle.

Without Sanity Functions, developers must string together a series of external services that they are responsible for documenting and maintaining. This creates logic related to content that exists outside the rest of your content operations.

This complexity compounds as developers spend more time building infrastructure while authors wait.

Organizations struggle to maintain consistent workflows and reliable content delivery at scale without a unified system for extending content operations.

Co-locating "what happens next" with the rest of your content infrastructure keeps everything organized and streamlined.

Introducing Sanity Functions (and Blueprints!)

Sanity Functions are authored in TypeScript and deployed to the Content Lake. Deploying them requires the first use of the next evolution of Sanity configuration, which we call "Blueprints."

Blueprints represent the best-in-class developer experience for developing and deploying content operations.

The Sanity Content Operating System comprises of deployable infrastructure components for content creation, maintenance, and the post-event lifecycle. It is backed by the Content Lake, a content-optimized, real-time datastore for documents and assets.

The future of Blueprints is infrastructure-as-code to configure all your content operations.

Write, react, repeat

Event-driven workflow

Sanity Functions allow you to respond to changes in your content. When a document is created, updated, or deleted, your function can execute custom logic to maintain data consistency, trigger workflows, or perform automated tasks. This event-driven approach ensures your content stays synchronized and follows business rules in real-time.

Complete context

Sanity Functions can read and write to your dataset, access other documents, and utilize the full Sanity API capabilities. Functions run with the same permissions as your applications, allowing them to perform complex operations while maintaining security. They can query related documents, traverse references, and make informed decisions based on the broader content context.

Extensibility

You can create reusable functions to maintain consistency across your content model and extend functionality across projects. Functions can be packaged as reusable modules and shared between different Sanity projects, making it easier to maintain consistent behavior and reduce code duplication. This modular approach allows you to build a library of tested, reliable functions that can be applied wherever needed.

New: Scheduled Functions

Functions can now run on a recurring schedule, not just in response to content changes. Define a cron expression in your Blueprint to automate nightly syncs, periodic cache invalidation, scheduled notifications, and more. Get started with Scheduled Functions.

Guide: Create, deploy, and test a function

Let's create a Sanity Function that adds the date and time to a "Post" type document the first time it is published.

This guide assumes you have a Sanity Studio with "Post" type documents and a dateTime field named firstPublished. If not, create a new free Sanity Studio project with the command below and choose the "blog" template.

Functions can be initialized with the Sanity CLI. As they are configured and deployed as part of a Blueprint, you'll need to create one of those first.

Create a new Blueprint

Run the following inside of your Sanity Studio project to initialize a new Blueprint:

You should now have two new files:

  • blueprint.json at the root of your project, which contains configuration for the functions you'll create. It deliberately contains no project-specific details such as your Sanity Project ID, so that the configuration is portable between projects.
  • .sanity/blueprint.config.json with project-specific configuration. This file shouldn't be checked into version control.

Create a new function

Run the following to add your first function to the project:

Name the function first-published

You'll now have a functions folder in your project, which are referenced inside the blueprint.json configuration file.

Along with all your other project files, you should now have these in your project:

Update the blueprint.json file to include a filter and projection

  • The filter will ensure the Function only fires on "Post" document types that do not yet have a value in the firstPublished field.
  • The projection will pass along only the _id attribute from the document to the function.

Run the following to test the Function locally using the CLI

You should receive a response like the below:

Take a look in functions/first-published/index.ts to see the code that generated this response.

Add Sanity Client

To patch documents, you'll need to install Sanity Client to the Function's dependencies. We'll also now install a package that contains helper functions to improve the TypeScript support of our function.

Run the following command from inside the first-published folder:

Update the function to create a new client instance using options provided from the handler's context.

Deploying your Blueprint and Function

Run the following command to deploy your Blueprint from the root of your project

In your Studio, create and publish a new "post" type document. Almost immediately after publishing you should see a firstPublished value written to the document.

Sanity Studio dashboard showing title, slug and first published fields
"First published" is a read-only field that has been written to by the Sanity Function

Run the following to view production activity from the first-published function.

You should see logs like below to confirm what you saw in your Sanity Studio.

And that's it! You can now continue to modify your Sanity Function to perform other tasks, add more functions to your project and redeploy the Blueprint at any time.

What will you do with Functions?

Updating documents isn't all you can do to support the content lifecycle with Sanity Functions. Consider what other functionality you could build. Here are some powerful use case ideas:

  • Summarize, tag or embellish content with AI Actions
  • Validate content before proceeding
  • Update documents with new data
  • Trigger external services (CDN, Algolia, Slack)
  • Handle multiple steps in a workflow

Join the discussion

We can't wait to see what you'll wire up with Functions. If you'd love to show it off, tag us on social media or join our community on Discord and post up in the Showcase channel.