Skip to content

fix(navigation): fix client-side navigation with reactive useAsyncData keys - #214

Merged
wazolab merged 3 commits into
developfrom
fix/client-side-navigation
Aug 2, 2026
Merged

wazolab merged 3 commits into
developfrom
fix/client-side-navigation

Conversation

@wazolab

@wazolab wazolab commented Jul 31, 2026

Copy link
Copy Markdown
Member

Closes #213

Root cause

app.vue used :page-key="route.path" which forced [...slug].vue to be destroyed and recreated on every navigation. Since [...slug].vue contains <NuxtLayout name="docs">, this also destroyed and recreated docs.vue via NuxtLayoutProvider. The slot content from the new [...slug].vue instance failed to propagate correctly into the new docs.vue during the Suspense transition — resulting in the sidebar remaining visible but the main content not updating.

Additionally, the useAsyncData keys were static strings computed once at component setup. Even though the component was being recreated, the async data mechanism had subtle timing issues with the Suspense boundary and KeepAlive that prevented content updates.

Fix

app.vue: Change page-key from route.path to locale.

  • [...slug].vue now persists across navigation within the same locale.
  • It is only recreated on language switch, which is the correct time to reset state (forces fresh docs.vue setup with the new locale's navigation data).

pages/[...slug].vue: Change all useAsyncData keys from static strings to reactive function form (() => 'key-...').

  • Nuxt 4 tracks reactive dependencies inside the key function. When slug or locale changes, the key function returns a different string, triggering a data refresh.
  • The component ([...slug].vue) stays alive; only the reactive data updates, which Vue re-renders in-place.
  • Removed the redundant watch: [locale] option from the navigation query (now handled by the reactive key function).

Behaviour after fix

  • Clicking sidebar links updates the main content immediately.
  • Next/prev buttons work on the first click.
  • The sidebar and accordion state persist across navigation (no unnecessary remounts).
  • Language switch still correctly resets the page component.

wazolab and others added 3 commits July 28, 2026 16:41
…vigation

Replace static useAsyncData keys with function form (reactive) in [...slug].vue
so that page data updates when the route changes without recreating the component.

Change page-key from route.path to locale in app.vue so that [...slug].vue
persists across in-locale navigation and is only recreated on language switch.

Fixes #213
@wazolab
wazolab merged commit 7c4ce5f into develop Aug 2, 2026
1 check failed
@wazolab
wazolab deleted the fix/client-side-navigation branch August 2, 2026 10:51
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.

fix(navigation): client-side navigation is broken

1 participant