How I set up Sanity AI Assist for editors in a Next.js project
Jul 06, 2026 · 6 min read
Sanity AI Assist — the @sanity/assist Studio plugin — lets editors run AI commands directly inside Sanity Studio without touching any code. Drafting a field, translating a snippet, summarising a long body, generating SEO metadata: all of it happens in-place, triggered by the editor, inside the same Studio your team already uses. Here is how I wire it up in a Next.js + Sanity project and which instruction patterns have actually been useful.
Heads up: AI Assist is actively evolving. This post covers what is stable and documented as of mid-2026. Always treat the official Sanity AI Assist docs as the authoritative reference — API surface and option names can change between minor releases.
What Sanity AI Assist actually does
AI Assist is a Studio-side plugin. It does not touch your Next.js application code at all. The plugin adds an "AI" button to fields you configure, and when an editor clicks it they can choose from preset instructions you define or type a freeform prompt. The response fills the field directly. Translation, tone adjustments, summarisation, and field-specific generation all run through Sanity's hosted AI layer — you do not manage an OpenAI key yourself, but you do need an eligible Sanity plan (check current plan eligibility on the pricing page before you start).
From a Next.js perspective the integration is transparent. The Next.js app reads published content from the Sanity Content Lake exactly as it does today — AI-generated text is just content. No extra API calls, no SDK changes on the frontend.
Installing and configuring the plugin
Start inside your Sanity Studio workspace. If you followed the embedded Studio pattern common in Next.js App Router projects, your Studio lives at something like app/studio/[[...tool]]/page.tsx with a sanity.config.ts at the project root.
# Run this inside your project root (where package.json lives)
npm install @sanity/assistThen register the plugin in sanity.config.ts:
// sanity.config.ts
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
import { assist } from '@sanity/assist'
export default defineConfig({
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,
plugins: [
structureTool(),
assist(), // Add this. No required options for basic setup.
],
schema: {
types: [
// your schema types
],
},
})That is the minimum. Deploy or run next dev (the embedded Studio refreshes automatically with Turbopack), open Studio, and you should see the AI button appear on text fields once you enable instructions on them.
Defining useful AI instructions on schema fields
The plugin becomes genuinely useful when you attach assist annotations to specific fields in your schemas. This is where you invest the most time — the quality of instructions directly determines whether editors trust the feature or ignore it.
Here is a practical example for a blog post schema. I keep schemas in sanity/schemas/.
// sanity/schemas/post.ts
import { defineField, defineType } from 'sanity'
import { assist } from '@sanity/assist'
export const post = defineType({
name: 'post',
title: 'Post',
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
}),
defineField({
name: 'excerpt',
title: 'Excerpt',
type: 'text',
rows: 3,
components: {
// Enables the AI Assist UI on this field
field: assist({
instructions: [
{
title: 'Generate excerpt from title',
prompt:
'Write a 1–2 sentence excerpt for a blog post with this title. ' +
'Plain prose, no hype, under 160 characters.',
},
{
title: 'Shorten to one sentence',
prompt: 'Condense this excerpt to a single clear sentence.',
},
],
}),
},
}),
defineField({
name: 'seoDescription',
title: 'SEO meta description',
type: 'string',
components: {
field: assist({
instructions: [
{
title: 'Generate SEO description',
prompt:
'Write a meta description for this post. ' +
'120–160 characters. Active voice. Include the post title naturally.',
},
],
}),
},
}),
],
})The assist() wrapper replaces the default field component with one that renders the AI trigger. Editors still see the normal input — the AI button sits alongside it. The instructions array is what appears in the dropdown when they click it.
A few things I have learned the hard way:
- Be specific about character limits. Editors trust output they do not have to rewrite. Vague prompts produce vague results.
- Reference sibling fields in prompts where the plugin allows it. The docs explain how to reference field values in instructions — check them for the current syntax because this part of the API has changed between minor versions.
- Do not add assist to every field. Portable Text body fields are usually better written by a human. I use AI Assist on structured fields: excerpt, meta description, SEO title, alt text, and social share copy.
How it fits a Next.js content workflow
The day-to-day flow for an editor looks like this: they open a post document in Studio, write or paste the title, click the AI button on the excerpt field, pick "Generate excerpt from title", review the output, tweak if needed, then publish. The published document hits the Content Lake. Your Next.js App Router pages pick it up via GROQ queries exactly as they do for any other content — nothing changes on the frontend.
If you are using ISR or on-demand revalidation (via Sanity webhooks to a Next.js route handler), the AI-generated content flows through that same pipeline. There is no special handling needed.
One workflow note worth calling out: AI Assist operates on draft documents. The editor reviews and approves before publishing. This is the right model — the AI is a writing assistant, not an autopublisher. Make that clear to your client or content team during onboarding, because the most common confusion I see is editors expecting AI to update the live site immediately.
Access control and plan considerations
AI Assist availability depends on your Sanity plan. As of mid-2026, the feature is available on Growth and Enterprise plans — verify current limits on sanity.io/pricing because this changes. Project members with Editor or higher roles can use it by default; you can tighten access through Sanity's role-based permissions if you want to restrict it to specific team members.
There is no configuration needed in Next.js itself — no environment variables to add, no API routes to create. The AI computation runs server-side within Sanity's infrastructure.
What I skip and why
I do not use AI Assist to generate Portable Text body content. Long-form generation inside a block editor produces inconsistent structure, and the editor ends up spending more time cleaning markup than they would writing from scratch. I also avoid using it on slug fields — slug logic should be deterministic and tied to validation, not a freeform AI suggestion.
The plugin earns its keep on the repetitive structured fields: SEO metadata, alt text, excerpts, social copy. Those are the fields editors consistently skip or fill with placeholder text, and they directly affect Next.js page metadata and Core Web Vitals scores (alt text feeds next/image, meta description feeds search CTR).
For anything beyond what is covered here — document-level translation, the @sanity/document-internationalization integration, or using AI instructions that reference multiple fields — start with the Sanity AI Assist documentation. The plugin's capabilities are expanding quickly and the docs reflect current state more reliably than any third-party post.