Skip to content

Add onWelcome prop on <SanityLive>#3515

Merged
stipsan merged 1 commit into
mainfrom
add-onWelcome-prop
May 11, 2026
Merged

Add onWelcome prop on <SanityLive>#3515
stipsan merged 1 commit into
mainfrom
add-onWelcome-prop

Conversation

@stipsan
Copy link
Copy Markdown
Member

@stipsan stipsan commented May 11, 2026

Split from #3109

Copilot AI review requested due to automatic review settings May 11, 2026 15:28
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
next-sanity Ready Ready Preview, Comment May 11, 2026 3:38pm
next-sanity-static Ready Ready Preview, Comment May 11, 2026 3:38pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 836103d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
next-sanity Minor

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

📚 TypeDoc Generation Result

TypeDoc generated successfully!

  • File size: 2.5M
  • Total exports: 266
  • Artifact: typedoc-aaef6362afcaaf6ba2e730441e9c98b4468dada7
  • HTML docs preview: Download artifact

The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | false to <SanityLive /> props and introduce the SanityLiveOnWelcome type.
  • Plumb onWelcome through defineLive and re-export the new type from the default, next-js, and react-server condition entrypoints.
  • Refine perspective typing by reusing LivePerspective in sanitizePerspective / 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.

Comment thread packages/next-sanity/src/live/shared/types.ts
Comment thread packages/next-sanity/src/live/shared/types.ts
Comment on lines +189 to +190
* This event fires when the EventSource connection is established. Some export
* conditions log a connection message by default; pass `false` to
Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • DefineLiveOptions no longer has a @public release tag comment even though defineLive itself is public and other option interfaces in the repo are annotated. If API/docs generation depends on these tags, consider restoring the @public annotation for DefineLiveOptions.
export interface DefineLiveOptions {
  /**
   * Sanity client used by `sanityFetch()` and `<SanityLive />`.
   */
  client: SanityClient

Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx
Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx
Comment thread packages/next-sanity/src/live/shared/types.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment on lines +189 to +190
* 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))
@stipsan stipsan merged commit 2096572 into main May 11, 2026
15 checks passed
@stipsan stipsan deleted the add-onWelcome-prop branch May 11, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants