Add onWelcome prop on <SanityLive>#3515
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 836103d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📚 TypeDoc Generation Result✅ TypeDoc generated successfully!
The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new onWelcome hook to the Sanity Live integration so consumers can customize (or disable) handling of the Live Content API welcome event, and wires the new type through the various next-sanity/live condition entrypoints.
Changes:
- Add
onWelcome?: SanityLiveOnWelcome | falseto<SanityLive />props and introduce theSanityLiveOnWelcometype. - Plumb
onWelcomethroughdefineLiveand re-export the new type from thedefault,next-js, andreact-servercondition entrypoints. - Refine perspective typing by reusing
LivePerspectiveinsanitizePerspective/ cookie-perspective resolution and add a changeset documenting the new prop.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/next-sanity/src/live/shared/types.ts | Adds onWelcome prop + SanityLiveOnWelcome type; adjusts public JSDoc annotations. |
| packages/next-sanity/src/live/shared/sanitizePerspective.ts | Switches return type to LivePerspective and removes unused ClientPerspective type import. |
| packages/next-sanity/src/live/conditions/react-server/index.ts | Re-exports SanityLiveOnWelcome. |
| packages/next-sanity/src/live/conditions/react-server/defineLive.tsx | Threads onWelcome through server component and uses LivePerspective for cookie resolution. |
| packages/next-sanity/src/live/conditions/next-js/index.ts | Re-exports SanityLiveOnWelcome. |
| packages/next-sanity/src/live/conditions/default/index.ts | Re-exports SanityLiveOnWelcome. |
| packages/next-sanity/src/live/client-components/SanityLive.tsx | Implements onWelcome invocation and adds a default welcome logger. |
| .changeset/twenty-schools-stick.md | Documents the new <SanityLive onWelcome> prop and how to disable the default message. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * This event fires when the EventSource connection is established. Some export | ||
| * conditions log a connection message by default; pass `false` to |
62890a4 to
eac2aab
Compare
eac2aab to
836103d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
packages/next-sanity/src/live/shared/types.ts:126
DefineLiveOptionsno longer has a@publicrelease tag comment even thoughdefineLiveitself is public and other option interfaces in the repo are annotated. If API/docs generation depends on these tags, consider restoring the@publicannotation forDefineLiveOptions.
export interface DefineLiveOptions {
/**
* Sanity client used by `sanityFetch()` and `<SanityLive />`.
*/
client: SanityClient
| * This event fires when the EventSource connection is established. | ||
| * The default event handler logs a message that adapts the message based on wether `includeDrafts` is set, and if `waitFor="function"` is set. |
| startTransition(() => setRefreshOnInterval(false)) | ||
|
|
||
| if (onWelcome) { | ||
| startTransition(() => onWelcome(event, actionContext)) |
Split from #3109