You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
9446c27 Thanks @stipsan! - Fix a regression introduced in v12.4.0 (#3430) that lead to live preview sometimes failing to refresh and show draft content automatically
<PortableText> now infers the shape of every component handler from the value prop. When you pass a value typed by Sanity TypeGen, components.types, components.marks, components.block, components.list, and components.listItem all receive precise value props for the exact content the query returned.
Three new utility types ship with this feature:
InferComponents<T> - same inference as the inline components prop, for hoisting components out of JSX.
InferStrictComponents<T> - strict variant that requires a handler for every inferred custom type, mark, block style, and list style, and rejects handlers that aren't in the schema (and therefore not visible to TypeGen).
InferValue<T> - derives a Portable Text array value type from any TypeGen query result type, useful for re-usable wrapper components.
Schema
Every example below assumes the same sanity.config.ts:
InferStrictComponents + InferValue: a strict, re-usable wrapper
InferValue<SanityQueries[keyof SanityQueries]> collects every Portable Text item shape from every registered TypeGen query into an array value type, and InferStrictComponents requires a handler for each of them. Together they're perfect for a single CustomPortableText you reuse across the app:
// app/[slug]/page.tsximport{createImageUrlBuilder}from"@​sanity/image-url";import{createClient,defineQuery,defineLive,PortableText,typeSanityQueries,typeInferValue,typeInferStrictComponents,}from"next-sanity";import{Image}from"next-sanity/image";import{notFound}from"next/navigation";constclient=createClient({projectId: "abc123",dataset: "production",useCdn: true,apiVersion: "2026-05-04",});constbuilder=createImageUrlBuilder(client);const{ sanityFetch }=defineLive({ client });functionCustomPortableText({
value,}: {// Array value type for every Portable Text item shape across all registered queries.value: InferValue<SanityQueries[keyofSanityQueries]>;}){constcomponents={types: {image: ({ value })=>(<imgsrc={builder.image(value).url()}alt={value.alt||""}/>),},}satisfiesInferStrictComponents<typeofvalue>;// ^ TypeScript errors when the schema gains a custom type, mark, or list// style without a matching handler defined herereturn<PortableTextcomponents={components}value={value}/>;}exportdefaultasyncfunctionPage({ params }: PageProps<"/[slug]">){const{ slug }=awaitparams;constquery=defineQuery(`*[_type == "post" && slug.current == $slug][0]{title,content}`);const{ data }=awaitsanityFetch({ query,params: { slug }});if(!data)returnnotFound();return(<article><h1>{data.title}</h1>{Array.isArray(data.content)&&(<CustomPortableTextvalue={data.content}/>)}</article>);}
#3430aa519e0 Thanks @stipsan! - Change <VisualEditing>'s default refresh behavior for document mutations to only call router.refresh(), and no longer call revalidatePath('/', 'layout') by default.
Technically this is a breaking change for apps relying on the previous default root layout revalidation. However, because of the Next.js regression reported by Sanity to Vercel in vercel/next.js#93210, we feel strongly that the default behavior in <VisualEditing> on document mutations needs to avoid revalidatePath('/', 'layout'): calling it worsens the impact of the regression by causing many CACHE: REVALIDATED events, which can massively increase ISR Writes.
The previous behavior can be restored by providing a custom refresh prop to <VisualEditing> that calls revalidatePath('/', 'layout'):
import{draftMode}from"next/headers";import{refresh,revalidatePath}from"next/cache";import{VisualEditing}from"next-sanity/visual-editing";exportdefaultasyncfunctionRootLayout({
children,}: {children: React.ReactNode;}){const{isEnabled: isDraftMode}=awaitdraftMode();return(<htmllang="en"><body>{children}{isDraftMode&&(<VisualEditingrefresh={asyncfunctionrefreshVisualEditing(payload){"use server";switch(payload.source){// When clicking the refresh button manually in Presentation Tool we purge the cachecase"manual":
returnrevalidatePath("/","layout");// When a document is edited we just refreshcase"mutation":
returnrefresh();default:
thrownewError("Unknown refresh source",{cause: payload,});}}}/>)}</body></html>);}
#343245b164b Thanks @stipsan! - Change <SanityLive />'s default revalidateSyncTags behavior so draft mode revalidates affected Sanity tags with revalidateTag(tag, 'max'), instead of expiring them immediately with revalidateTag(tag, {expire: 0}).
Technically this is a breaking change for apps relying on the previous immediate tag expiry behavior. However, because of the Next.js regression reported by Sanity to Vercel in vercel/next.js#93210, we feel strongly that the default behavior in <SanityLive /> needs to avoid revalidateTag(tag, {expire: 0}) in draft mode: calling it worsens the impact of the regression by causing many CACHE: REVALIDATED events, which can massively increase ISR Writes.
The previous behavior can be restored by providing a custom revalidateSyncTags prop to <SanityLive />:
#3433df0eb01 Thanks @stipsan! - Disallow using defineLive when cacheComponents: true is enabled.
Technically this is a breaking change for apps that currently combine defineLive with Next.js Cache Components. However, this configuration is not supported and can cause problems that are difficult to detect, so it is better to fail early until #3109 lands.
Patch Changes
#3430aa519e0 Thanks @stipsan! - Improve lazy loading of <SanityLive>, if not rendered it won't add <SanityLiveClientComponent /> to the bundle`
#3430aa519e0 Thanks @stipsan! - Improve lazy loading of <VisualEditing>, if not rendered it won't increase the browser bundle
12.3.5
Patch Changes
#34285d37ae2 Thanks @stipsan! - Automatically disable long polling when receives a reconnect or restart event
#34285d37ae2 Thanks @stipsan! - Stop calling prefetchDNS from 'react-dom' in <SanityLive>, calling preconnect is enough
#3419b2f026b Thanks @copilot-swe-agent! - Removed the experimental SanityLiveStream export from defineLive. While this is technically a breaking change, it does not follow semver as it was an experimental, undocumented API marked as @alpha. We will return with a different implementation in the future, once we've found an approach that works well with Next.js v16 and cache components.
[!WARNING]
This is a breaking change if you were using this implementation. Upgrade to next-sanity@cache-components if you want to continue testing the cache components implementation or wait for the stable release.
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@vercel/stega@1.1.0. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
10.1.1→12.4.5Release Notes
sanity-io/next-sanity (next-sanity)
v12.4.5Compare Source
Patch Changes
9446c27Thanks @stipsan! - Fix a regression introduced in v12.4.0 (#3430) that lead to live preview sometimes failing to refresh and show draft content automatically12.4.4
Patch Changes
8e9e032Thanks @stipsan! - fix(deps): update dependency @sanity/preview-url-secret to ^4.0.612.4.3
Patch Changes
#3455
abbd86bThanks @renovate! - fix(deps): update sanity monorepo to v5.24.0#3461
6231e5bThanks @renovate! - fix(deps): update dependency @portabletext/react to ^6.2.0TypeGen-aware Portable Text components
<PortableText>now infers the shape of every component handler from thevalueprop. When you pass a value typed by Sanity TypeGen,components.types,components.marks,components.block,components.list, andcomponents.listItemall receive precisevalueprops for the exact content the query returned.Three new utility types ship with this feature:
InferComponents<T>- same inference as the inlinecomponentsprop, for hoisting components out of JSX.InferStrictComponents<T>- strict variant that requires a handler for every inferred custom type, mark, block style, and list style, and rejects handlers that aren't in the schema (and therefore not visible to TypeGen).InferValue<T>- derives a Portable Text array value type from any TypeGen query result type, useful for re-usable wrapper components.Schema
Every example below assumes the same
sanity.config.ts:Before: hand-typing handlers
Previously, every handler had to be typed by hand to mirror the generated query shape:
After: automatic inference
Now the same handler is fully typed straight from
data.content:InferComponents: hoisting components without losing inferenceMove the
componentsmap out of JSX and keep the same inferred handler types:InferStrictComponents+InferValue: a strict, re-usable wrapperInferValue<SanityQueries[keyof SanityQueries]>collects every Portable Text item shape from every registered TypeGen query into an array value type, andInferStrictComponentsrequires a handler for each of them. Together they're perfect for a singleCustomPortableTextyou reuse across the app:12.4.2
Patch Changes
33340b0Thanks @renovate! - fix(deps): update dependency @portabletext/react to ^6.1.012.4.1
Patch Changes
f721d73Thanks @stipsan! - Improve dts output with better examples12.4.0
Minor Changes
#3430
aa519e0Thanks @stipsan! - Change<VisualEditing>'s default refresh behavior for document mutations to only callrouter.refresh(), and no longer callrevalidatePath('/', 'layout')by default.Technically this is a breaking change for apps relying on the previous default root layout revalidation. However, because of the Next.js regression reported by Sanity to Vercel in vercel/next.js#93210, we feel strongly that the default behavior in
<VisualEditing>on document mutations needs to avoidrevalidatePath('/', 'layout'): calling it worsens the impact of the regression by causing manyCACHE: REVALIDATEDevents, which can massively increase ISR Writes.The previous behavior can be restored by providing a custom
refreshprop to<VisualEditing>that callsrevalidatePath('/', 'layout'):#3432
45b164bThanks @stipsan! - Change<SanityLive />'s defaultrevalidateSyncTagsbehavior so draft mode revalidates affected Sanity tags withrevalidateTag(tag, 'max'), instead of expiring them immediately withrevalidateTag(tag, {expire: 0}).Technically this is a breaking change for apps relying on the previous immediate tag expiry behavior. However, because of the Next.js regression reported by Sanity to Vercel in vercel/next.js#93210, we feel strongly that the default behavior in
<SanityLive />needs to avoidrevalidateTag(tag, {expire: 0})in draft mode: calling it worsens the impact of the regression by causing manyCACHE: REVALIDATEDevents, which can massively increase ISR Writes.The previous behavior can be restored by providing a custom
revalidateSyncTagsprop to<SanityLive />:#3433
df0eb01Thanks @stipsan! - Disallow usingdefineLivewhencacheComponents: trueis enabled.Technically this is a breaking change for apps that currently combine
defineLivewith Next.js Cache Components. However, this configuration is not supported and can cause problems that are difficult to detect, so it is better to fail early until #3109 lands.Patch Changes
#3430
aa519e0Thanks @stipsan! - Improve lazy loading of<SanityLive>, if not rendered it won't add<SanityLiveClientComponent />to the bundle`#3430
aa519e0Thanks @stipsan! - Improve lazy loading of<VisualEditing>, if not rendered it won't increase the browser bundle12.3.5
Patch Changes
#3428
5d37ae2Thanks @stipsan! - Automatically disable long polling when receives areconnectorrestartevent#3428
5d37ae2Thanks @stipsan! - Stop callingprefetchDNSfrom 'react-dom' in<SanityLive>, callingpreconnectis enough#3428
5d37ae2Thanks @stipsan! - Wraprouter.refresh()instartTransition12.3.4
Patch Changes
daf1ddeThanks @stipsan! - Remove unusedserver-onlydependency12.3.3
Patch Changes
b2f026bThanks @copilot-swe-agent! - Removed the experimentalSanityLiveStreamexport fromdefineLive. While this is technically a breaking change, it does not follow semver as it was an experimental, undocumented API marked as@alpha. We will return with a different implementation in the future, once we've found an approach that works well with Next.js v16 and cache components.12.3.2
Patch Changes
#3415
fb456d0Thanks @renovate! - fix(deps): update sanity monorepo to v5.23.0#3414
ad68f4cThanks @copilot-swe-agent! - Fixed.js-suffixed bare imports (e.g.next/headers.js) in build output that broke Turbopack module resolution in app-route handlers12.3.1
Patch Changes
#3393
6474ddaThanks @renovate! - fix(deps): update sanity monorepo to v5.22.0#3395
51a2f2aThanks @renovate! - fix(deps): update dependency @sanity/client to ^7.22.0#3400
f92a7a4Thanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.3.412.3.0
Minor Changes
f2832ebThanks @adoprog! - feat(live): addwaitForoption to<SanityLive>to defer events until a Sanity Function has processed themPatch Changes
#3385
2cb8697Thanks @renovate! - fix(deps): update dependency @sanity/client to ^7.21.0#3389
2caa3a3Thanks @renovate! - fix(deps): update dependency @sanity/preview-url-secret to ^4.0.512.2.2
Patch Changes
609a9c2Thanks @renovate! - fix(deps): update sanity monorepo to v5.20.012.2.1
Patch Changes
1aa38caThanks @stipsan! - Reduce the risk of hitting API rate limits duringnext buildon large build machines12.2.0
Minor Changes
16c2e11Thanks @stipsan! - Remove experimental cache components implementation fordefineLivePatch Changes
97763caThanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.3.312.1.6
Patch Changes
eb9df7dThanks @renovate! - fix(deps): update sanity monorepo to v5.18.012.1.5
Patch Changes
71e609aThanks @stipsan! - Stop using['sanity']as the default fallback whensanityFetchdoes not specify customtags12.1.4
Patch Changes
b001dd9Thanks @renovate! - fix(deps): update dependency @sanity/client to ^7.20.012.1.3
Patch Changes
a9c9c4dThanks @stipsan! - Upgrade@sanity/visual-editingto ^5.3.1#3318
b888827Thanks @renovate! - fix(deps): update sanity monorepo to v5.17.1#3323
35aae81Thanks @renovate! - fix(deps): update dependency @sanity/preview-url-secret to ^4.0.4bcbd46dThanks @stipsan! - Upgrade@sanity/clientto ^7.18.0d9ef0a1Thanks @stipsan! - Upgrade@sanity/preview-url-secretto ^4.0.412.1.2
Patch Changes
#3304
b44f430Thanks @renovate! - fix(deps): update dependency @sanity/client to ^7.17.0#3313
e3801c9Thanks @renovate! - fix(deps): update sanity monorepo to v5.16.012.1.1
Patch Changes
#3269
2ac9366Thanks @renovate! - fix(deps): update sanity monorepo to v5.13.0#3271
767ef51Thanks @renovate! - fix(deps): update dependency @sanity/client to ^7.16.0#3274
da9965eThanks @renovate! - fix(deps): update dependency @portabletext/react to ^6.0.3#3289
971289cThanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.3.012.1.0
Minor Changes
#3250
d206756Thanks @stipsan! - AdduseVisualEditingEnvironmenthook#3250
d206756Thanks @stipsan! - RefactoruseIsPresentationToolimplementation to no longer require<SanityLive />, it uses<VisualEditing />instead.Patch Changes
#3255
7d4a0c0Thanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.2.1#3250
d206756Thanks @stipsan! - MarkuseDraftModeEnvironment,useDraftModePerspective, anduseIsLivePreview, as deprecated12.0.17
Patch Changes
#3233
3588da9Thanks @renovate! - fix(deps): update dependency @sanity/preview-url-secret to ^4.0.3#3234
68d467fThanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.1.2#3242
55cb929Thanks @renovate! - fix(deps): update sanity monorepo to v5.8.0#3249
ba5873dThanks @renovate! - fix(deps): update sanity monorepo to v5.8.112.0.16
Patch Changes
8ae31a4Thanks @stipsan! - Remove@sanity/browserslist-configdependency12.0.15
Patch Changes
#3210
fda7c94Thanks @renovate! - fix(deps): update dependency @sanity/client to ^7.14.1#3217
99751f3Thanks @renovate! - fix(deps): update sanity monorepo to v5.7.0bcf4dd1Thanks @stipsan! - Stop inlining@sanity/webhook12.0.14
Patch Changes
bdd6cfcThanks @renovate! - fix(deps): update sanity monorepo to v5.5.012.0.13
Patch Changes
5ff22ecThanks @renovate! - fix(deps): update sanity monorepo to v5.4.012.0.12
Patch Changes
44cc987Thanks @renovate! - fix(deps): update sanity monorepo to v5.3.012.0.11
Patch Changes
cac530bThanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.1.012.0.10
Patch Changes
86b032eThanks @renovate! - fix(deps): update sanity monorepo to v5.2.012.0.9
Patch Changes
11e4b16Thanks @renovate! - fix(deps): update dependency @sanity/client to ^7.14.012.0.8
Patch Changes
#3139
4f7bc10Thanks @renovate! - fix(deps): update dependency @portabletext/react to ^6.0.2#3140
d895e94Thanks @renovate! - fix(deps): update dependency @sanity/preview-url-secret to ^4.0.2#3141
9cbb189Thanks @renovate! - fix(deps): update dependency @sanity/visual-editing to ^5.0.412.0.7
Patch Changes
0cde2edThanks @renovate! - fix(deps): update dependency @portabletext/react to ^6.0.112.0.6
Patch Changes
2e2148cThanks @renovate! - fix(deps): update sanity monorepo to v5.1.012.0.5
Patch Changes
a0e4920Thanks @stipsan! - Reduce bundlesize ofisCorsOriginError12.0.4
Patch Changes
2264834Thanks @stipsan! - Remove@sanity/typesdev dependency12.0.3
Patch Changes
18f7392Thanks @stipsan! - Inline@sanity/typesinnext-sanity/webhook12.0.2 (2025-12-18)
Bug Fixes
12.0.1 (2025-12-17)
Bug Fixes
12.0.0 (2025-12-16)
⚠ BREAKING CHANGES
Features
Bug Fixes
Miscellaneous Chores
next@16(c0e159a)11.6.12 (2025-12-16)
Bug Fixes
11.6.11 (2025-12-15)
Bug Fixes
11.6.10 (2025-11-26)
Bug Fixes
11.6.9 (2025-11-25)
Bug Fixes
11.6.8 (2025-11-19)
Bug Fixes
11.6.7 (2025-11-17)
Bug Fixes
11.6.6 (2025-11-11)
Bug Fixes
11.6.5 (2025-11-05)
Bug Fixes
11.6.4 (2025-11-03)
Bug Fixes
11.6.3 (2025-10-31)
Bug Fixes
11.6.2 (2025-10-24)
Bug Fixes
11.6.1 (2025-10-24)
Bug Fixes
11.6.0 (2025-10-24)
Features
use cache:remote(#2909) (4423dee)11.5.7 (2025-10-23)
Bug Fixes
revalidateTagwarning on v16 (2023512)11.5.6 (2025-10-21)
Bug Fixes
11.5.5 (2025-10-16)
Bug Fixes
11.5.4 (2025-10-16)
Bug Fixes
11.5.3 (2025-10-16)
Bug Fixes
11.5.2 (2025-10-16)
Bug Fixes
11.5.1 (2025-10-15)
Bug Fixes
11.5.0 (2025-10-15)
Features
11.4.2 (2025-09-26)
Bug Fixes
server-onlyimport at the top (f1faca8)11.4.1 (2025-09-25)
Bug Fixes
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate using a curated preset maintained by
. View repository job log here