This commit is contained in:
Tomas Dvorak
2026-02-24 10:33:59 +01:00
parent 409acd2e08
commit 898a3c303f
1374 changed files with 290409 additions and 29187 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"id": "4b088e1b818e39fc2919b096",
"source": "solid:signals",
"type": "github-document",
"title": "use-search-params",
"content": "---\ntitle: useSearchParams\nuse_cases: \"pagination, filters, search forms, url state management, query string updates\"\ntags:\n - search\n - query\n - params\n - pagination\n - filters\n - url\nversion: \"1.0\"\ndescription: \u003e-\n Manage URL query parameters with useSearchParams - handle pagination, filters,\n and search state directly in the URL query string.\n---\n\nThe `useSearchParams` function reads the URL query parameters for the current route and provides a function to update them.\n\n## Import\n\n```ts\nimport { useSearchParams } from \"@solidjs/router\";\n```\n\n## Type\n\n```ts\nfunction useSearchParams\u003cT extends Record\u003cstring, string | string[]\u003e\u003e(): [\n\tPartial\u003cT\u003e,\n\t(params: SetSearchParams, options?: Partial\u003cNavigateOptions\u003e) =\u003e void,\n];\n```\n\n## Parameters\n\n`useSearchParams` takes no arguments.\n\n## Return value\n\n- **Type:** `[ Partial\u003cT\u003e, (params: SetSearchParams, options?: Partial\u003cNavigateOptions\u003e) =\u003e void ]`\n\n`useSearchParams` returns an array with two items.\n\nThe first item is a reactive object containing the current query parameters.\nAccessing a property within a tracking scope registers a dependency, causing the computation to re-run when the parameter changes.\nValues are always strings.\n\nThe second item is a function that updates the query string.\nIt merges the object provided as its first argument with the current query parameters.\nPassing an empty string (`\"\"`), an empty array (`[]`), `undefined`, or `null` as a value removes the key.\nIt accepts the same options as [`useNavigate`](/solid-router/reference/primitives/use-navigate) as the second parameter.\nBy default, the `resolve` and `scroll` options are set to `false`.\n\n## Examples\n\n### Basic usage\n\n```tsx\nimport { useSearchParams } from \"@solidjs/router\";\n\nfunction Paginator() {\n\tconst [params, setParams] = useSearchParams();\n\n\tconst page = () =\u003e Number(params.page || \"1\");\n\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003cspan\u003eCurrent Page: {page()}\u003c/span\u003e\n\t\t\t\u003cbutton onClick={() =\u003e setParams({ page: page() + 1 })}\u003eNext\u003c/button\u003e\n\t\t\u003c/div\u003e\n\t);\n}\n```\n\n## Related\n\n- [`useParams`](/solid-router/reference/primitives/use-params)\n- [`useLocation`](/solid-router/reference/primitives/use-location)\n- [`useNavigate`](/solid-router/reference/primitives/use-navigate)",
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/solid-router/reference/primitives/use-search-params.mdx",
"metadata": {
"path": "src/routes/solid-router/reference/primitives/use-search-params.mdx",
"repo": "solidjs/solid-docs",
"repo_url": "https://github.com/solidjs/solid-docs.git",
"size": 2214,
"source_type": "github"
},
"hash": "fe93338fde21ce485581dbc3670fc5a956c0ec9c03495b16e39504ca6784c42d",
"timestamp": "2026-02-23T11:43:00.193273335+01:00"
}