# Interface RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>

Context for raw HTTP request handlers (onRequest).

interface RequestContext<
TState,
TConnParams,
TConnState,
TVars,
TInput,
TDatabase extends AnyDatabaseProvider,
> {
conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
request: Request | undefined;
get abortSignal(): AbortSignal;
get actorId(): string;
get conns(): Map<
string,
Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>,
>;
get db(): InferDatabaseClient<TDatabase>;
get key(): string[];
get log(): Logger;
get name(): string;
get region(): string;
get schedule(): Schedule;
get state(): TState;
get vars(): TVars;
broadcast<Args extends unknown[]>(name: string, ...args: Args): void;
client<R extends Registry<any>>(): Client<R>;
saveState(opts: SaveStateOptions): Promise<void>;
sleep(): void;
waitUntil(promise: Promise<void>): void;
}

#### Type Parameters

- TState
- TConnParams
- TConnState
- TVars
- TInput
- TDatabase extends AnyDatabaseProvider

#### Hierarchy

- ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>
  - RequestContext

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/request.ts:9

##### Index

### Properties

conn
request

### Accessors

abortSignal
actorId
conns
db
key
log
name
region
schedule
state
vars

### Methods

broadcast
client
saveState
sleep
waitUntil

## Properties

### `Readonly` conn

conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>

Inherited from ConnContext.conn

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/conn.ts:37

### `Readonly` request

request: Request | undefined

The incoming HTTP request. May be undefined for request contexts initiated without a direct HTTP request.

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/request.ts:28

## Accessors

### abortSignal

- get abortSignal(): AbortSignal

  AbortSignal that fires when the actor is stopping.

  #### Returns AbortSignal

  Inherited from ConnContext.abortSignal

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:154

### actorId

- get actorId(): string

  Gets actor ID.

  #### Returns string

  Inherited from ConnContext.actorId

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:77

### conns

- get conns(): Map<
  string,
  Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>,
  >

  Gets the map of connections.

  #### Returns Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>

  Inherited from ConnContext.conns

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:112

### db

- get db(): InferDatabaseClient<TDatabase>
  `Experimental`

  Gets the database.

  #### Returns InferDatabaseClient<TDatabase>

  #### Throws

  If the database is not enabled.

  Inherited from ConnContext.db

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:131

### key

- get key(): string[]

  Gets the actor key.

  #### Returns string[]

  Inherited from ConnContext.key

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:91

### log

- get log(): Logger

  Gets the logger instance.

  #### Returns Logger

  Inherited from ConnContext.log

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:70

### name

- get name(): string

  Gets the actor name.

  #### Returns string

  Inherited from ConnContext.name

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:84

### region

- get region(): string

  Gets the region.

  #### Returns string

  Inherited from ConnContext.region

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:98

### schedule

- get schedule(): Schedule

  Gets the scheduler.

  #### Returns Schedule

  Inherited from ConnContext.schedule

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:105

### state

- get state(): TState

  Get the actor state

  #### Returns TState

  Inherited from ConnContext.state

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:46

### vars

- get vars(): TVars

  Get the actor variables

  #### Returns TVars

  Inherited from ConnContext.vars

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:53

## Methods

### broadcast

- broadcast<Args extends unknown[]>(name: string, ...args: Args): void

  Broadcasts an event to all connected clients.

  #### Type Parameters

  - Args extends unknown[]

  #### Parameters

  - name: string

    The name of the event.

  - ...args: Args

    The arguments to send with the event.

  #### Returns void

  Inherited from ConnContext.broadcast

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:62

### client

- client<R extends Registry<any>>(): Client<R>

  Returns the client for the given registry.

  #### Type Parameters

  - R extends Registry<any>

  #### Returns Client<R>

  Inherited from ConnContext.client

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:122

### saveState

- saveState(opts: SaveStateOptions): Promise<void>

  Forces the state to get saved.

  #### Parameters

  - opts: SaveStateOptions

    Options for saving the state.

  #### Returns Promise<void>

  Inherited from ConnContext.saveState

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:140

### sleep

- sleep(): void
  `Experimental`

  Forces the actor to sleep.

  Not supported on all drivers.

  #### Returns void

  Inherited from ConnContext.sleep

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:165

### waitUntil

- waitUntil(promise: Promise<void>): void

  Prevents the actor from sleeping until promise is complete.

  #### Parameters

  - promise: Promise<void>

  #### Returns void

  Inherited from ConnContext.waitUntil

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/contexts/actor.ts:147