Skip to content

Query state boolean default to true: does not init url + calling setter with false does put false in url #1050

@remi-van

Description

@remi-van

Context

What's your version of nuqs?

"nuqs": "^2.4.3",

What framework are you using?

  • ❌ Next.js (app router)
  • ❌ Next.js (pages router)
  • ❌ React SPA (no router)
  • ❌ Remix
  • ✅ React Router
  • ❌ Other (please specify)

Which version of your framework are you using?

"react": "^19.0.0",
"react-router": "^7.5.2",

Description

When initializing query state boolean to true (useQueryState("bool", parseAsBoolean.withDefault(true))), setting value to false (setBool(false)) will update the url params bool=false, and won't when setting it to true (empty url params). The behavior is inverted, it should update the url for true, not false.

Expected: When default boolean query state to true, it should update the url with the query param.

Reproduction

Cannot provide reproduction, because on stackblitz, it seems it doesn't update the URL when setting query state. (https://stackblitz.com/edit/vitejs-vite-qp7k4iak)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions