Inside a remote command or form callback, returns an iterable
of { arg, query } entries for the query instances the client asked to refresh, up to
the supplied limit. Each query is a RemoteQuery bound to the original
client-side cache key, so refresh() / set() propagate correctly even when
the query's schema transforms the input. arg is the validated argument,
i.e. the value after the schema has run (so InferOutput<Schema> for queries
declared with a Standard Schema).
Arguments that fail validation or exceed limit are recorded as failures in
the response to the client.
See Client-requested refreshes
for usage in a remote command or form.
import{requested}from'$app/server';for(const{arg,query}ofrequested(getPost,5)){// `arg` is the validated argument; `query` is bound to the client's// cache key. It's safe to throw away this promise -- SvelteKit will// await it and forward any errors to the client.voidquery.refresh();}
As a shorthand for the above, you can also call refreshAll on the result:
functionform<SchemaextendsStandardSchemaV1<RemoteFormInput,Record<string,any>>,Output>(validate:trueextendsHasNonOptionalBoolean<StandardSchemaV1.InferInput<Schema>>?'Error: All booleans in form schemas must be optional (e.g. `v.optional(v.boolean(), false)`) because checkbox inputs do not send a false value when unchecked.':Schema,fn:(data:StandardSchemaV1.InferOutput<Schema>,issue:InvalidField<StandardSchemaV1.InferInput<Schema>>)=>MaybePromise<Output>):RemoteForm<StandardSchemaV1.InferInput<Schema>,Output>;
getRequestEvent
Available since 2.20.0
Returns the current RequestEvent. Can be used inside server hooks, server load functions, actions, and endpoints (and functions called by them).
In environments without AsyncLocalStorage, this must be called synchronously (i.e. not after an await).
functiongetRequestEvent():RequestEvent;
prerender
Available since 2.27
Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a fetch call.
Inside a remote command or form callback, returns an iterable
of { arg, query } entries for the query instances the client asked to refresh, up to
the supplied limit. Each query is a RemoteQuery bound to the original
client-side cache key, so refresh() / set() propagate correctly even when
the query’s schema transforms the input. arg is the validated argument,
i.e. the value after the schema has run (so InferOutput<Schema> for queries
declared with a Standard Schema).
Arguments that fail validation or exceed limit are recorded as failures in
the response to the client.
See Client-requested refreshes
for usage in a remote command or form.
Inside a remote command or form callback, returns an iterable
of { arg, query } entries for the query instances the client asked to refresh, up to
the supplied limit. Each query is a RemoteQuery bound to the original
client-side cache key, so refresh() / set() propagate correctly even when
the query's schema transforms the input. arg is the validated argument,
i.e. the value after the schema has run (so InferOutput<Schema> for queries
declared with a Standard Schema).
Arguments that fail validation or exceed limit are recorded as failures in
the response to the client.
See Client-requested refreshes
for usage in a remote command or form.
import{requested}from'$app/server';for(const{arg,query}ofrequested(getPost,5)){// `arg` is the validated argument; `query` is bound to the client's// cache key. It's safe to throw away this promise -- SvelteKit will// await it and forward any errors to the client.voidquery.refresh();}
As a shorthand for the above, you can also call refreshAll on the result:
Inside a remote command or form callback, returns an iterable
of { arg, query } entries for the query instances the client asked to refresh, up to
the supplied limit. Each query is a RemoteQuery bound to the original
client-side cache key, so refresh() / set() propagate correctly even when
the query's schema transforms the input. arg is the validated argument,
i.e. the value after the schema has run (so InferOutput<Schema> for queries
declared with a Standard Schema).
Arguments that fail validation or exceed limit are recorded as failures in
the response to the client.
See Client-requested refreshes
for usage in a remote command or form.
import{requested}from'$app/server';for(const{arg,query}ofrequested(getPost,5)){// `arg` is the validated argument; `query` is bound to the client's// cache key. It's safe to throw away this promise -- SvelteKit will// await it and forward any errors to the client.voidquery.refresh();}
As a shorthand for the above, you can also call refreshAll on the result:
Works with query.batch as well — refreshes for individual entries are
collected into a single batched call.
For live queries, the same applies, but with reconnect and reconnectAll.
reference(getPostany,5)){ // `arg` is the validated argument; `query` is bound to the client's // cache key. It's safe to throw away this promise -- SvelteKit will // await it and forward any errors to the client.voidqueryconstquery:RemoteQuery<unknown>.refresh(method)refresh():Promise<void>
On the client, this function will re-fetch the query from the server.
On the server, this can be called in the context of a command or form and the refreshed data will accompany the action response back to the client.
This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
();}
As a shorthand for the above, you can also call refreshAll on the result:
Inside a remote command or form callback, returns an iterable
of { arg, query } entries for the query instances the client asked to refresh, up to
the supplied limit. Each query is a RemoteQuery bound to the original
client-side cache key, so refresh() / set() propagate correctly even when
the query's schema transforms the input. arg is the validated argument,
i.e. the value after the schema has run (so InferOutput<Schema> for queries
declared with a Standard Schema).
Arguments that fail validation or exceed limit are recorded as failures in
the response to the client.
See Client-requested refreshes
for usage in a remote command or form.
import{requested}from'$app/server';for(const{arg,query}ofrequested(getPost,5)){// `arg` is the validated argument; `query` is bound to the client's// cache key. It's safe to throw away this promise -- SvelteKit will// await it and forward any errors to the client.voidquery.refresh();}
As a shorthand for the above, you can also call refreshAll on the result:
Inside a remote command or form callback, returns an iterable
of { arg, query } entries for the query instances the client asked to refresh, up to
the supplied limit. Each query is a RemoteQuery bound to the original
client-side cache key, so refresh() / set() propagate correctly even when
the query's schema transforms the input. arg is the validated argument,
i.e. the value after the schema has run (so InferOutput<Schema> for queries
declared with a Standard Schema).
Arguments that fail validation or exceed limit are recorded as failures in
the response to the client.
See Client-requested refreshes
for usage in a remote command or form.
import{requested}from'$app/server';for(const{arg,query}ofrequested(getPost,5)){// `arg` is the validated argument; `query` is bound to the client's// cache key. It's safe to throw away this promise -- SvelteKit will// await it and forward any errors to the client.voidquery.refresh();}
As a shorthand for the above, you can also call refreshAll on the result:
namespacequery{/*** Creates a batch query function that collects multiple calls and executes them in a single request** See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.**@since2.35*/functionbatch<Input,Output>(validate:'unchecked',fn:(args:Input[])=>MaybePromise<(arg:Input,idx:number)=>Output>):RemoteQueryFunction<Input,Output>;/*** Creates a batch query function that collects multiple calls and executes them in a single request** See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.**@since2.35*/functionbatch<SchemaextendsStandardSchemaV1,Output>(schema:Schema,fn:(args:StandardSchemaV1.InferOutput<Schema>[])=>MaybePromise<(arg:StandardSchemaV1.InferOutput<Schema>,idx:number)=>Output>):RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>,Output,StandardSchemaV1.InferOutput<Schema>>;/*** Creates a live remote query. When called from the browser, the function will be invoked on the server via a streaming `fetch` call.** See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.live) for full documentation.** */functionlive<Output>(fn:(arg:void)=>RemoteLiveQueryUserFunctionReturnType<Output>):RemoteLiveQueryFunction<void,Output>;functionlive<Input,Output>(validate:'unchecked',fn:(arg:Input)=>RemoteLiveQueryUserFunctionReturnType<Output>):RemoteLiveQueryFunction<Input,Output>;functionlive<SchemaextendsStandardSchemaV1,Output>(schema:Schema,fn:(arg:StandardSchemaV1.InferOutput<Schema>)=>RemoteLiveQueryUserFunctionReturnType<Output>):RemoteLiveQueryFunction<StandardSchemaV1.InferInput<Schema>,Output,StandardSchemaV1.InferOutput<Schema>>;}