> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/honojs/hono/llms.txt
> Use this file to discover all available pages before exploring further.

# Adapter Helper

> Runtime detection and environment access

The Adapter Helper provides utilities for detecting the runtime environment and accessing environment variables.

## Import

```typescript theme={null}
import { env, getRuntimeKey } from 'hono/adapter'
```

## Functions

### env()

Get environment variables and bindings in a type-safe way.

```typescript theme={null}
function env<T extends Record<string, any> = Record<string, any>, C extends Context = Context>(
  c: C
): T & C['env']['Bindings']
```

<ParamField path="c" type="Context" required>
  The context object
</ParamField>

<ResponseField name="return" type="T & Bindings">
  Environment variables and bindings
</ResponseField>

**Example**

```typescript theme={null}
import { env } from 'hono/adapter'

app.get('/', (c) => {
  const { DATABASE_URL, API_KEY } = env(c)
  return c.text(`Using database: ${DATABASE_URL}`)
})
```

### getRuntimeKey()

Detect the current JavaScript runtime.

```typescript theme={null}
function getRuntimeKey(): 
  | 'node' 
  | 'deno' 
  | 'bun' 
  | 'workerd' 
  | 'fastly' 
  | 'edge-light' 
  | 'other'
```

<ResponseField name="return" type="RuntimeKey">
  The detected runtime key
</ResponseField>

**Example**

```typescript theme={null}
import { getRuntimeKey } from 'hono/adapter'

const runtime = getRuntimeKey()
console.log(`Running on ${runtime}`)

if (runtime === 'deno') {
  // Deno-specific code
} else if (runtime === 'bun') {
  // Bun-specific code
}
```

## Type-Safe Environment

```typescript theme={null}
import { env } from 'hono/adapter'

type Env = {
  Bindings: {
    DATABASE_URL: string
    API_KEY: string
  }
}

app.get('/', (c) => {
  const { DATABASE_URL, API_KEY } = env<Env['Bindings']>(c)
  // TypeScript knows these are strings
})
```
