Nt 2571 implement react web sdk root provider components and related hooks#161
Merged
Lotfi Anwar L Arif (Lotfi-Arif) merged 15 commits intomainfrom Mar 4, 2026
Conversation
…r-components-and-related-hooks
- Update OptimizationRoot and OptimizationProvider to accept SDK config props (clientId, environment, analytics, etc.) instead of an instance - Update README and usage docs to reflect new initialization pattern - Update dev and test apps to use config-as-props pattern - Improve error messages and test coverage for provider usage - Remove legacy instance-based initialization code
Charles Hudson (phobetron)
previously approved these changes
Mar 3, 2026
Collaborator
Charles Hudson (phobetron)
left a comment
There was a problem hiding this comment.
Awesome!
- Use OptimizationConfig for provider props - Change useLiveUpdates to throw outside provider - Remove logLevel from dev config - Update live updates resolution example - Export OptimizationConfig type from web SDK
Charles Hudson (phobetron)
approved these changes
Mar 4, 2026
Collaborator
Charles Hudson (phobetron)
left a comment
There was a problem hiding this comment.
Only thing I think probably needs to change (after this PR) is the necessity of the types in the types.ts file. We can go over that separately to ensure we understand what's going on, what's available, and what should be available.
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.
Summary
Implemented React Web core parity primitives for
@contentful/optimization-react-web:OptimizationContext+OptimizationProvider(requiredinstance)useOptimization()with actionable error outside providerLiveUpdatesContext+LiveUpdatesProvider(global live updates state)useLiveUpdates()(nullable outside provider)Implemented
OptimizationRootas the recommended wrapperUpdated public exports from package entrypoint.
Added/updated unit tests to cover:
useOptimization()error behavior outside providerliveUpdatesuseOptimization()+useLiveUpdates()usage underOptimizationRootcomponent override -> root -> false)Updated package README with usage and provider requirements
Wired minimal dev harness integration:
@contentful/optimization-webinstanceOptimizationRoot