We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
parseAsPageIndex
1 parent 2779419 commit b628d95Copy full SHA for b628d95
packages/nuqs/src/parsers.ts
@@ -155,6 +155,17 @@ export const parseAsInteger = createParser({
155
serialize: v => Math.round(v).toFixed()
156
})
157
158
+export const parseAsPageIndex = createParser({
159
+ parse: (v) => {
160
+ const int = parseInt(v);
161
+ if (Number.isNaN(int)) {
162
+ return null;
163
+ }
164
+ return int - 1;
165
+ },
166
+ serialize: (v) => Math.round(v + 1).toFixed(),
167
+});
168
+
169
export const parseAsHex = createParser({
170
parse: v => {
171
const int = parseInt(v, 16)
0 commit comments