Repository navigation
fix: let useConfig() inside UI components take precedence upon client-side navigation (vikejs/vike#3525) - #251
Merged
Merged
Conversation
…-side navigation (vikejs/vike#3525) Upon client-side navigation, the settings set by useConfig() (or <Config>) inside UI components were applied to the DOM while rendering, and then overwritten by onRenderClient() applying the settings set by +data() or +config. Since Solid renders the page synchronously upon setPageContext(), we now apply the settings of +data() and +config before rendering the page, so that the settings applied by UI components while rendering take precedence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vKLUPaAR8j8CqQfKQEa6M
This was referenced Sep 25, 2026
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.
Fixes the vike-solid side of vikejs/vike#3525. The same bug is fixed in vike-react by vikejs/vike-react#230.
Bug
Upon client-side navigation, a
titleset byuseConfig()(or<Config>) inside a UI component got overwritten by the title set by+data()(viauseConfig()) or by+title.Cause: Solid renders the new page synchronously inside
setPageContext(). During that render, components apply their settings to the DOM directly, because'_headAlreadySet' in pageContextis always true on the client. Right after,onRenderClient()applied the+data()/+configsettings, overwriting the components' values.Fix
onRenderClient()now applies the+data()/+confighead settings before rendering the page upon client-side navigation. The settings components apply while rendering then take precedence, which matches SSR (components > Vike hooks > page settings > global settings). There's no visible flash, since the page renders synchronously in the same task.Why not reuse vike-react's approach (store the value in
pageContext._configFromHookwhile rendering, apply it afterwards):usePageContext()returns a Solid store. The store holds a copy ofpageContext's properties and ignores writes made through it, so components can't reachpageContext._configFromHookor observe_headAlreadySetchanging without extra workarounds.Tests (
examples/full)/images:<Image>now sets<Config title>, mirroring vike-vue's example, and a new+data()sets a title viauseConfig(). Tests check that the component's title wins in the HTML, after hydration, and after client-side navigation. They also check that the title doesn't leak to the next page.useConfig() in UI components upon client-side navigationfails withexpected 'Images' to equal 'Image created by Romuald Brillout'.fullandsolid-query, dev and preview), as dotest:types,lintandformat:check.Related PRs
🤖 Generated with Claude Code
https://claude.ai/code/session_016vKLUPaAR8j8CqQfKQEa6M