Skip to content
Discussion options

You must be logged in to vote

Current hook if anyone is interested:

'use client'

import { usePathname, useRouter, useSearchParams } from 'next/navigation'
import { useEffect, useMemo, useRef } from 'react'
import type { ZodType } from 'zod'

export interface UseQueryParamSyncOptions<T> {
	key: string
	value: T
	setValue?: (nextValue: T) => void
	/**
	 * Debounce delay in milliseconds for URL updates. Default: 300ms
	 */
	debounceMs?: number
	/**
	 * Whether to hydrate the value only once on mount (true) or on every URL change (false).
	 * - `true`: Hydrate once on mount, ignore subsequent URL changes
	 * - `false` (default): Hydrate on every URL parameter change
	 */
	hydrateOnce?: boolean
	/**
	 * Whether to use rou…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by franky47
Comment options

You must be logged in to vote
2 replies
@demianeen-minimal
Comment options

@franky47
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants