Skip to content

fix(suggestions): add nextjs and ssr support to suggestions widget - #7119

Draft
shaejaz wants to merge 40 commits into
masterfrom
fix/chat-ssr-sessionstorage-guard
Draft

fix(suggestions): add nextjs and ssr support to suggestions widget#7119
shaejaz wants to merge 40 commits into
masterfrom
fix/chat-ssr-sessionstorage-guard

Conversation

@shaejaz

@shaejaz shaejaz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

shaejaz and others added 10 commits July 14, 2026 12:33
# 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>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 56 complexity

Metric Results
Complexity 56

View in Codacy

TIP This summary will be updated as you push new changes.

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown
More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@7119

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@7119

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@7119

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@7119

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@7119

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@7119

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@7119

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@7119

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@7119

commit: 6384dbd

Base automatically changed from feat/chat-page-suggestions-widget to master August 3, 2026 14:18
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.

1 participant