import type { ComponentPlugin } from '@teleporthq/teleport-types'; /** * Registers the `useRouter` dependency and injects `const router = useRouter()` * at the top of the component body whenever the UIDL declares page-level URL * search params that downstream dynamic references consume — i.e. * `uidl.searchParams` driving `referenceType: 'urlSearchParams'` bindings, * already handled by `buildNextJsUrlSearchParamsPrelude` / * `createDynamicValueExpression`. * * Also handles state-level `urlSearchParamBinding` by emitting two paired * `useEffect`s per such state: * * 1. **Write-back** (state → URL): when the user picks a new value, push * it onto the URL via `router.replace(..., { shallow: true })`. Empty * / null state deletes the key entirely so the URL doesn't keep a * sticky `?key=` empty param. * 2. **Read-back** (URL → state): when the URL changes without the page * remounting (shallow `router.push`, browser back/forward), sync the * state to match. The functional setter form (`prev => prev === next * ? prev : next`) prevents an infinite loop with the write-back effect. * * Without write-back the initial read (`createStateHookAST` → * `window.location.search`) hydrates the state on load, but user-driven * changes never propagate to the URL bar and cross-page deep links built * off the URL break. Without read-back the state goes stale on shallow * navigations that change the URL but keep the page mounted. * * Runs AFTER `createReactComponentPlugin` (so the component chunk exists) * and is idempotent with the internationalization plugin, which may have * already set `dependencies.useRouter` and emitted the same declaration. */ export declare const createNextUrlSearchParamsPlugin: () => ComponentPlugin; //# sourceMappingURL=url-search-params-plugin.d.ts.map