{
  "id": "0d261abfd8c636473ac51300",
  "source": "solid:signals",
  "type": "github-document",
  "title": "revalidate",
  "content": "---\ntitle: revalidate\nuse_cases: \u003e-\n  refresh data, invalidate cache, polling, real-time updates, manual refetch,\n  stale data\ntags:\n  - revalidate\n  - cache\n  - refresh\n  - invalidation\n  - polling\n  - refetch\nversion: \"1.0\"\ndescription: \u003e-\n  Manually revalidate cached queries to refresh stale data, implement polling,\n  or trigger updates after mutations in SolidJS.\n---\n\nThe `revalidate` function triggers revalidation of [queries](/solid-router/data-fetching/queries) by their keys.\nEach query with active subscribers re-executes and updates its dependents; queries without subscribers are marked stale but don't execute until subscribed.\n\n## Import\n\n```tsx\nimport { revalidate } from \"@solidjs/router\";\n```\n\n## Type\n\n```tsx\nfunction revalidate(\n\tkey?: string | string[] | void,\n\tforce?: boolean\n): Promise\u003cvoid\u003e;\n```\n\n## Parameters\n\n### `key`\n\n- **Type:** `string | string[] | void`\n- **Required:** No\n\nThe query key or array of query keys to revalidate.\nIf not provided, all queries on the current page are revalidated.\n\n### `force`\n\n- **Type:** `boolean`\n- **Required:** No\n- **Default:** `true`\n\nWhen `true`, clears the internal cache used for deduplication.\nWhen `false`, allows cached data to be reused if available.\n\n## Return value\n\n`revalidate` returns a `Promise` that resolves when the revalidation transition completes.\n\n## Examples\n\n### Basic usage\n\n```tsx\nimport { query, createAsync, revalidate } from \"@solidjs/router\";\n\nconst getUserQuery = query(async () =\u003e {\n\t// ... Fetches user data.\n\treturn { name: \"John\" };\n}, \"user\");\n\nfunction UserProfile() {\n\tconst user = createAsync(() =\u003e getUserQuery());\n\n\tfunction refreshUser() {\n\t\trevalidate(getUserQuery.key);\n\t}\n\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003cbutton onClick={refreshUser}\u003eRefresh\u003c/button\u003e\n\t\t\t\u003cp\u003e{user()?.name}\u003c/p\u003e\n\t\t\u003c/div\u003e\n\t);\n}\n```\n\n### Revalidating multiple queries\n\n```tsx\nimport { query, revalidate } from \"@solidjs/router\";\n\nconst getUsersQuery = query(async () =\u003e {\n\t// ... Fetches users.\n}, \"users\");\n\nconst getPostsQuery = query(async () =\u003e {\n\t// ... Fetches posts.\n}, \"posts\");\n\nfunction refreshAll() {\n\trevalidate([getUsersQuery.key, getPostsQuery.key]);\n}\n```\n\n## Related\n\n- [`query`](/solid-router/reference/data-apis/query)\n- [`createAsync`](/solid-router/reference/data-apis/create-async)",
  "url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/solid-router/reference/data-apis/revalidate.mdx",
  "metadata": {
    "path": "src/routes/solid-router/reference/data-apis/revalidate.mdx",
    "repo": "solidjs/solid-docs",
    "repo_url": "https://github.com/solidjs/solid-docs.git",
    "size": 2268,
    "source_type": "github"
  },
  "hash": "68c8cb53b6cb7aca23ec247851d6e8c14b6de4a941ecfd77ceb3b2452b8f2725",
  "timestamp": "2026-02-23T11:43:00.192758367+01:00"
}