Skip to content

feat: Full-page navigation option for shallow: false updates in React SPA#891

Merged
franky47 merged 5 commits intonextfrom
feat/react-spa-shallow-false-page-reload
Feb 17, 2025
Merged

feat: Full-page navigation option for shallow: false updates in React SPA#891
franky47 merged 5 commits intonextfrom
feat/react-spa-shallow-false-page-reload

Conversation

@franky47
Copy link
Member

@franky47 franky47 commented Feb 1, 2025

This allows using the React SPA adapter with a backend server catching the search param updates configured with shallow: false. For example, this can be useful when paired with a server written in other languages than JavaScript: Rails, Laravel, Django, Phoenix etc, that serves a statically built React SPA bundle.

It's disabled by default to keep compatibility with existing code (where shallow: false doesn't do anything), but it might be switched on by default in nuqs@3.0.0 (TBC).

Usage

import { NuqsAdapter } from 'nuqs/adapters/react'
import { createRoot } from 'react-dom/client'

createRoot(document.getElementById('root')!).render(
  <NuqsAdapter fullPageNavigationOnShallowFalseUpdates>
    <App />
  </NuqsAdapter>
)

Tasks

  • Add e2e test (might require matricing the e2e-react job)
  • Add docs
  • Update the branch protection before merging
  • Do a test with Django or Phoenix

@franky47 franky47 added feature New feature or request adapters/react Uses the React SPA adapter labels Feb 1, 2025
@franky47 franky47 added this to the 🪵 Backlog milestone Feb 1, 2025
@vercel
Copy link

vercel bot commented Feb 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 17, 2025 10:26am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 1, 2025

pnpm add https://pkg.pr.new/nuqs@891

commit: c475b13

@franky47 franky47 force-pushed the feat/react-spa-shallow-false-page-reload branch from b9240fe to 3fd1a6a Compare February 17, 2025 10:14
We're not doing a page reload, but a full page navigation.
@franky47 franky47 changed the title feat: Allow shallow: false updates to reload the page in React SPA feat: Full-page navigation option for shallow: false updates in React SPA Feb 17, 2025
@franky47 franky47 merged commit 48cae6b into next Feb 17, 2025
29 checks passed
@franky47 franky47 deleted the feat/react-spa-shallow-false-page-reload branch February 17, 2025 10:33
@github-actions
Copy link

🎉 This PR is included in version 2.4.0-beta.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@franky47 franky47 removed this from the 🚀 Shipping next milestone Feb 17, 2025
@franky47 franky47 mentioned this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adapters/react Uses the React SPA adapter feature New feature or request released on @beta released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant