$app/server
import { function command<Output>(fn: () => Output): RemoteCommand<void, Output> (+2 overloads)
Creates a remote command. When called from the browser, the function will be invoked on the server via a fetch
call.
See Remote functions for full documentation.
command, function form<Output>(fn: () => MaybePromise<Output>): RemoteForm<void, Output> (+2 overloads)
Creates a form object that can be spread onto a <form>
element.
See Remote functions for full documentation.
form, function getRequestEvent(): RequestEvent
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
).
getRequestEvent, function prerender<Output>(fn: () => MaybePromise<Output>, options?: { inputs?: RemotePrerenderInputsGenerator<void>; dynamic?: boolean; } | undefined): RemotePrerenderFunction<void, Output> (+2 overloads)
Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a fetch
call.
See Remote functions for full documentation.
prerender, function query<Output>(fn: () => MaybePromise<Output>): RemoteQueryFunction<void, Output> (+2 overloads)
Creates a remote query. When called from the browser, the function will be invoked on the server via a fetch
call.
See Remote functions for full documentation.
query, function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read } from '$app/server';
command
Available since 2.27
Creates a remote command. When called from the browser, the function will be invoked on the server via a fetch
call.
See Remote functions for full documentation.
function command<Output>( fn: () => Output ): RemoteCommand<void, Output>;
function command<Input, Output>( validate: 'unchecked', fn: (arg: Input) => Output ): RemoteCommand<Input, Output>;
function command<Schema extends StandardSchemaV1, Output>( validate: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Output ): RemoteCommand< StandardSchemaV1.InferInput<Schema>, Output >;
form
Available since 2.27
Creates a form object that can be spread onto a <form>
element.
See Remote functions for full documentation.
function form<Output>( fn: ( invalid: import('@sveltejs/kit').Invalid<void> ) => MaybePromise<Output> ): RemoteForm<void, Output>;
function form<Input extends RemoteFormInput, Output>( validate: 'unchecked', fn: ( data: Input, invalid: import('@sveltejs/kit').Invalid<Input> ) => MaybePromise<Output> ): RemoteForm<Input, Output>;
function form< Schema extends StandardSchemaV1< RemoteFormInput, Record<string, any> >, Output >( validate: Schema, fn: ( data: StandardSchemaV1.InferOutput<Schema>, invalid: import('@sveltejs/kit').Invalid< StandardSchemaV1.InferOutput<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
).
function getRequestEvent(): 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.
See Remote functions for full documentation.
function prerender<Output>( fn: () => MaybePromise<Output>, options?: | { inputs?: RemotePrerenderInputsGenerator<void>; dynamic?: boolean; } | undefined ): RemotePrerenderFunction<void, Output>;
function prerender<Input, Output>( validate: 'unchecked', fn: (arg: Input) => MaybePromise<Output>, options?: | { inputs?: RemotePrerenderInputsGenerator<Input>; dynamic?: boolean; } | undefined ): RemotePrerenderFunction<Input, Output>;
function prerender<Schema extends StandardSchemaV1, Output>( schema: Schema, fn: ( arg: StandardSchemaV1.InferOutput<Schema> ) => MaybePromise<Output>, options?: | { inputs?: RemotePrerenderInputsGenerator< StandardSchemaV1.InferInput<Schema> >; dynamic?: boolean; } | undefined ): RemotePrerenderFunction< StandardSchemaV1.InferInput<Schema>, Output >;
query
Available since 2.27
Creates a remote query. When called from the browser, the function will be invoked on the server via a fetch
call.
See Remote functions for full documentation.
function query<Output>( fn: () => MaybePromise<Output> ): RemoteQueryFunction<void, Output>;
function query<Input, Output>( validate: 'unchecked', fn: (arg: Input) => MaybePromise<Output> ): RemoteQueryFunction<Input, Output>;
function query<Schema extends StandardSchemaV1, Output>( schema: Schema, fn: ( arg: StandardSchemaV1.InferOutput<Schema> ) => MaybePromise<Output> ): RemoteQueryFunction< StandardSchemaV1.InferInput<Schema>, Output >;
read
Available since 2.4.0
Read the contents of an imported asset from the filesystem
import { function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read } from '$app/server'; import const somefile: string
somefile from './somefile.txt'; const const asset: Response
asset = function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read(const somefile: string
somefile); const const text: string
text = await const asset: Response
asset.Body.text(): Promise<string>
text();
function read(asset: string): Response;
query
namespace query { /** * 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. * * @since 2.35 */ function batch<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. * * @since 2.35 */ function batch<Schema extends StandardSchemaV1, Output>( schema: Schema, fn: ( args: StandardSchemaV1.InferOutput<Schema>[] ) => MaybePromise< ( arg: StandardSchemaV1.InferOutput<Schema>, idx: number ) => Output > ): RemoteQueryFunction< StandardSchemaV1.InferInput<Schema>, Output >; }
Edit this page on GitHub llms.txt