fix(suggestions): add nextjs and ssr support to suggestions widget - #7119
Draft
shaejaz wants to merge 40 commits into
Draft
fix(suggestions): add nextjs and ssr support to suggestions widget#7119shaejaz wants to merge 40 commits into
shaejaz wants to merge 40 commits into
Conversation
The example wiring isn't needed for now; reverts examples/ back to master. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # packages/instantsearch.js/src/lib/ai-lite/abstract-chat.ts
# Conflicts: # packages/instantsearch.js/src/lib/server.ts # packages/react-instantsearch-nextjs/src/InitializePromise.ts # packages/react-instantsearch-nextjs/src/__tests__/InitializePromise.test.tsx
`getDefaultInitialMessages` and `saveMessagesInLocalStorage` in the Chat state access `sessionStorage` unconditionally. Under server-side rendering (e.g. the Next.js App Router integration) `sessionStorage` is undefined, so constructing a `Chat` on the server throws `ReferenceError: sessionStorage is not defined`. Guard both paths with `typeof sessionStorage === 'undefined'` and wrap the read in try/catch so SSR falls back to empty initial messages and skips persistence, restoring it on the client. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The SSR guard for `sessionStorage` in the Chat state is moved to its own PR (fix/chat-ssr-sessionstorage-guard) since it touches internal lib/chat files and reviews more clearly on its own. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ssionstorage-guard
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 56 |
TIP This summary will be updated as you push new changes.
More templates
algoliasearch-helper
instantsearch-ui-components
instantsearch.css
instantsearch.js
react-instantsearch
react-instantsearch-core
react-instantsearch-nextjs
react-instantsearch-router-nextjs
vue-instantsearch
commit: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.