Open
Description
Context
What's your version of nuqs
?
"nuqs": "^1.19.2"
Next.js information (obtained by running next info
):
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.1.0: Mon Oct 9 21:32:11 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6030
Available memory (MB): 18432
Available CPU cores: 11
Binaries:
Node: 20.14.0
npm: 10.7.0
Yarn: 1.22.22
pnpm: 8.15.5
Relevant Packages:
next: 14.2.10 // There is a newer version (14.2.13) available, upgrade recommended!
eslint-config-next: 14.2.4
react: 18.3.1
react-dom: 18.3.1
typescript: 5.3.3
Next.js Config:
output: standalone
⚠ There is a newer version (14.2.13) available, upgrade recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Are you using:
- ✅ The app router
- ❌ The pages router
- ❌ The
basePath
option in your Next.js config - ❌ The experimental
windowHistorySupport
flag in your Next.js config
Description
When having an array of strings define like this in the useQueryState:
const [ids, setIds] = useQueryState(
"ids"
parseAsArrayOf(parseAsString).withOptions({ shallow: false, scroll: false, clearOnDefault: true }),
);
And a query like this in the browser:
?ids=
I expect ids to be:
['']
instead I receive:
[]

this happens because of (https://github.com/47ng/nuqs/issues/329). But in my opinion this should have never been approved since at the moment there's no way to represent empty value.
Possible solution can be have 2 parsers, one called parseAsNonEmptyArrayOf (name is an example, i'm sure there is a better name for it), and that returns "" if query is there but no value is there