```js // @noErrors import { command, form, getRequestEvent, prerender, query, 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](/docs/kit/remote-functions#command) for full documentation.
```dts function command( fn: () => Output ): RemoteCommand; ```
```dts function command( validate: 'unchecked', fn: (arg: Input) => Output ): RemoteCommand; ```
```dts function command( validate: Schema, fn: (arg: StandardSchemaV1.InferOutput) => Output ): RemoteCommand< StandardSchemaV1.InferOutput, Output >; ```
## form
Available since 2.27
Creates a form object that can be spread onto a `
` element. See [Remote functions](/docs/kit/remote-functions#form) for full documentation.
```dts function form( fn: (data: FormData) => MaybePromise ): RemoteForm; ```
## 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`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
```dts function getRequestEvent(): RequestEvent< AppLayoutParams<'/'>, any >; ```
## 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](/docs/kit/remote-functions#prerender) for full documentation.
```dts function prerender( fn: () => MaybePromise, options?: | { inputs?: RemotePrerenderInputsGenerator; dynamic?: boolean; } | undefined ): RemotePrerenderFunction; ```
```dts function prerender( validate: 'unchecked', fn: (arg: Input) => MaybePromise, options?: | { inputs?: RemotePrerenderInputsGenerator; dynamic?: boolean; } | undefined ): RemotePrerenderFunction; ```
```dts function prerender( schema: Schema, fn: ( arg: StandardSchemaV1.InferOutput ) => MaybePromise, options?: | { inputs?: RemotePrerenderInputsGenerator< StandardSchemaV1.InferOutput >; dynamic?: boolean; } | undefined ): RemotePrerenderFunction< StandardSchemaV1.InferOutput, 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](/docs/kit/remote-functions#query) for full documentation.
```dts function query( fn: () => MaybePromise ): RemoteQueryFunction; ```
```dts function query( validate: 'unchecked', fn: (arg: Input) => MaybePromise ): RemoteQueryFunction; ```
```dts function query( schema: Schema, fn: ( arg: StandardSchemaV1.InferOutput ) => MaybePromise ): RemoteQueryFunction< StandardSchemaV1.InferOutput, Output >; ```
## read
Available since 2.4.0
Read the contents of an imported asset from the filesystem ```js // @errors: 7031 import { read } from '$app/server'; import somefile from './somefile.txt'; const asset = read(somefile); const text = await asset.text(); ```
```dts function read(asset: string): Response; ```