mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-04 12:33:04 +00:00
17 lines
2.2 KiB
JSON
17 lines
2.2 KiB
JSON
{
|
|
"id": "4c51bf63993e434b3dc73a0f",
|
|
"source": "solid:signals",
|
|
"type": "github-document",
|
|
"title": "use-params",
|
|
"content": "---\ntitle: useParams\nuse_cases: \"dynamic routes, user profiles, product pages, id-based content, url parameters\"\ntags:\n - params\n - dynamic\n - routes\n - parameters\n - reactive\nversion: \"1.0\"\ndescription: \u003e-\n Access route parameters reactively with useParams - extract dynamic segments\n from URLs for user profiles, products, and ID-based pages.\n---\n\nThe `useParams` function reads the path parameters of the current route.\n\n## Import\n\n```ts\nimport { useParams } from \"@solidjs/router\";\n```\n\n## Type\n\n```ts\nfunction useParams\u003cT extends Record\u003cstring, string\u003e\u003e(): T;\n```\n\n## Parameters\n\n`useParams` takes no arguments.\n\n## Return value\n\n- **Type**: `T`\n\n`useParams` returns a reactive object where keys match the dynamic segments defined in the route path.\nAccessing a property within a tracking scope registers a dependency, causing the computation to re-run when the parameter changes.\n\n## Examples\n\n### Basic usage\n\n```ts\nimport { createMemo } from \"solid-js\";\nimport { useParams } from \"@solidjs/router\";\n\n// Rendered via \u003cRoute path=\"/users/:id\" component={UserPage} /\u003e\nfunction UserPage() {\n const params = useParams();\n\n // Derived value updates when the route parameter changes.\n const title = createMemo(() =\u003e `Profile for ${params.id}`);\n\n return \u003ch1\u003e{title()}\u003c/h1\u003e;\n}\n```\n\n## Related\n\n- [useLocation](/solid-router/reference/primitives/use-location)\n- [useSearchParams](/solid-router/reference/primitives/use-search-params)",
|
|
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/solid-router/reference/primitives/use-params.mdx",
|
|
"metadata": {
|
|
"path": "src/routes/solid-router/reference/primitives/use-params.mdx",
|
|
"repo": "solidjs/solid-docs",
|
|
"repo_url": "https://github.com/solidjs/solid-docs.git",
|
|
"size": 1444,
|
|
"source_type": "github"
|
|
},
|
|
"hash": "105138cc15f4dbab46c58544223197b26e376e7d48ca6689394dd4013ef32e50",
|
|
"timestamp": "2026-02-23T11:43:00.193173688+01:00"
|
|
} |