# Runtime Context

**URL:** https://heroiclabs.com/docs/nakama/server-framework/introduction/runtime-context/
**Summary:** Nakama includes a fast embedded code runtime for writing custom logic as JavaScript bundles, Go plugins, and Lua modules. Learn the basics of using the server runtime features.
**Keywords:** ctx, context
**Categories:** nakama, runtime-context, introduction

---


# Runtime Context

All registered functions across all runtimes receive a `context` as the first argument. This contains fields which depend on when and how the code is executed. You can extract information about the request or the user making it from the context:

{{< code type="server" >}}
```lua
local user_id = context.user_id
```
{{< / code >}}

{{< code type="server" >}}
```go
userId, ok := ctx.Value(runtime.RUNTIME_CTX_USER_ID).(string)
if !ok {
  // User ID not found in the context.
}
```
{{< / code >}}

{{< code type="server" >}}
```typescript
let userId = ctx.userId;
```
{{< / code >}}

The Go runtime context is a standard `context.Context` type and its fields can be accessed as shown above. 

In JavaScript, context is a plain object with properties.

If you are writing your runtime code in Lua, the `context` will be a table from which you can access the fields directly. 

{{< table name="nakama.server-framework.basics.context" >}}

## Go context

The runtime context is distinct from the [Go context](https://pkg.go.dev/context). It is important that a `Context` type be included in all server requests to avoid a potential overloading of the server with dead requests (i.e. requests from users who have since disconnected).

Inclusion of the `Context` allows for the context cancellation - when a user's HTTP connection to the server is closed - to be propagated across the entire chain of requests and avoid the processing and/or buildup of such dead requests.

