Add standalone engine definition to SSR-Next search #6613
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.
Adds
standaloneEngineDefinitiontodefineSearchEngine()return value, mirroring commerce SSR-Next pattern. Enables pages with standalone search boxes to skip unnecessary server-side search execution.Changes
New standalone static state factory
standalone-static-state-factory.ts: Initializes controllers without callingengine.executeFirstSearch()searchActionsarrayUpdated
defineSearchEngine()return typeBoth definitions share
hydrateStaticState,getAccessToken,setAccessToken. Standalone uses separatefetchStaticStatethat skips search execution.Fixed hydration for empty search actions
hydrated-state-factory.ts: Only waits forwaitForSearchCompletedAction()whensearchActions.length > 0Usage
Backward compatible via destructuring.
Original prompt
This section details on the original issue you should resolve
<issue_title>[DXUI Feature]: Support SSR standalone components</issue_title>
<issue_description>### Feature Description
Feature Request
Add standalone search engine definition support to SSR-Next search implementation (
packages/headless/src/ssr-next/search/).Currently,
fetchStaticState()always executes a server-side search, even for standalone search boxes that only need query suggestions and redirection functionality. This creates unnecessary:Note: This is a new feature for
ssr-next/only (not a breaking change). The olderssr/implementation will remain unchanged.Current Behavior
Desired Behavior
Add a new
standaloneEngineDefinitionoption (similar to commerce SSR-Next) that:standaloneEngineDefinitiondefineSearchEngine()usage continues to workReference Implementation
Commerce SSR-Next already implements this pattern in
packages/headless/src/ssr-next/commerce/engine/commerce-engine.ssr.ts:In commerce's
ssr-next/commerce/factories/static-state-factory.ts:Proposed Implementation
1. Update
defineSearchEngineto Return Multiple Engine DefinitionsIMPORTANT: This changes the return type, making it a new feature rather than modifying existing behavior.
2. Create Standalone Static State Factory
Create a new factory that skips search execution:
3. Update Engine Definition to Export Both
Files to Create/Modify
New Files
packages/headless/src/ssr-next/search/factories/standalone-static-state-factory.ts- Factory that skips search executionpackages/headless/src/ssr-next/search/factories/standalone-static-state-factory.test.ts- Tests for standalone factoryModified Files
packages/headless/src/ssr-next/search/engine/search-engine.ssr.ts- Update return type and add standalone definition✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.