Repository navigation
fix: let useConfig() inside UI components take precedence upon client-side navigation (vikejs/vike#3525) - #230
Merged
Merged
Conversation
This was referenced Sep 25, 2026
brillout
force-pushed
the
claude/sharp-goodall-t1gcwp
branch
from
September 25, 2026 09:03
ba10f6b to
c534ab9
Compare
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 bug reported at vikejs/vike#3525.
Bug
Upon client-side navigation, a
titleset byuseConfig()(or<Config>) inside a UI component briefly showed up, and then got overwritten by the title set by+data()(viauseConfig()) or by+title.Cause:
useConfig-client.tschecked'_headAlreadySet' in pageContextinstead of the flag's value. SinceonRenderClient()always setspageContext._headAlreadySet(tofalseupon client-side navigation), components always wrote todocument.titledirectly while rendering. Then, afterawait renderPromise,onRenderClient()appliedpageContext._configViaHook(values from+data()) orpageContext.config.title, overwriting the component's value.Fix
useConfig-client.tschecks!pageContext._headAlreadySet(likeuseConfig-server.tsand vike-vue do). While the page renders during client-side navigation, component values are now stored inpageContext._configViaHookand applied byonRenderClient(). They're stored after the values set by Vike hooks, so they take precedence, which matches SSR:useConfig()inside UI componentsuseConfig()inside Vike hookssetPageContextConfigViaHook()skipsundefinedvalues, like the server-side version does. Otherwiseconfig({ title: maybeUndefined })in a component would now wipe the title set by+data().Second fix:
pageContext.config.streammutated between requestsThe new test surfaced an unrelated bug that the preview test
+react.{server.client}.jshad only passed by luck.resolveStreamSetting()calledstream?.reverse(), which reverses the sharedpageContext.config.streamarray in place. In production, the precedence of+streamvalues therefore flips on every request: the landing page ofexamples/full(stream: false, while the global config hasstream: true) was streamed on every other request. Fixed by copying before reversing, asgetHeadSetting()already does. This is a separate commit.Tests (
examples/full)/images:<Image>now sets<Config title>, 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.+react.{server.client}.jsnow runs twice in a row, so it deterministically catches thestreammutation.useConfig() in UI components upon client-side navigationfails withexpected 'Images' to equal 'Image created by Romuald Brillout'.+react.{server.client}.js (request 1)fails in preview.test:types,test:unitsandformat:check.Related PRs
🤖 Generated with Claude Code
https://claude.ai/code/session_016vKLUPaAR8j8CqQfKQEa6M