diff --git a/apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md b/apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md index 072e3270db..e4d5e12e6e 100644 --- a/apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md +++ b/apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md @@ -161,9 +161,9 @@ export const getPost = query(v.string(), async (slug) => { Both the argument and the return value are serialized with [devalue](https://github.com/sveltejs/devalue), which handles types like `Date` and `Map` (and custom types defined in your [transport hook](hooks#Universal-hooks-transport)) in addition to JSON. -### Refreshing queries +### Updating queries -Any query can be updated via its `refresh` method: +Any query can be re-fetched via its `refresh` method, which retrieves the latest value from the server: ```svelte ``` -> [!NOTE] Queries are cached while they're on the page, meaning `getPosts() === getPosts()`. This means you don't need a reference like `const posts = getPosts()` in order to refresh the query. +Alternatively, if you need to update its value manually, you can use the `set` method: + +```svelte + +``` + +> [!NOTE] Queries are cached while they're on the page, meaning `getPosts() === getPosts()`. This means you don't need a reference like `const posts = getPosts()` in order to update the query. ## form diff --git a/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md b/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md index 557e08020f..59049da645 100644 --- a/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md +++ b/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md @@ -2191,6 +2191,12 @@ type RemotePrerenderFunction = ( ```dts type RemoteQuery = RemoteResource & { + /** + * On the client, this function will update the value of the query without re-fetching it. + * + * On the server, this throws an error. + */ + set(value: T): void; /** * On the client, this function will re-fetch the query from the server. *