---
title: "Handler and context"
description: "Handler is a resource or a route function to send data back to client. Context contains information about each request."
url: "https://next.elysiajs.com/tutorial/getting-started/handler-and-context/"
---

# Handler and context

**Handler** - a resource or a route function to send data back to client.

```ts
import { Elysia } from 'elysia'

new Elysia()
    // `() => 'hello world'` is a handler
    .get('/', () => 'hello world')
    .listen(3000)
```

A handler can also be a literal value, see [Handler](/essential/handler/)

```ts
import { Elysia } from 'elysia'

new Elysia()
    // `'hello world'` is a handler
    .get('/', 'hello world')
    .listen(3000)
```

Using an inline value can be useful for static resources like **files**.

## Context

Contains information about each request. It is passed as the only argument of a handler.

```typescript
import { Elysia } from 'elysia'

new Elysia()
  .get('/', (context) => context.path)
            // ^ This is a context
```

**Context** stores information about the request like:

- [body](/essential/validation/#body) - data sent by client to server like form data, JSON payload.
- [query](/essential/validation/#query) - query string as an object. (Query is extracted from a value after pathname starting from ’?’ question mark sign)
- [params](/essential/validation/#params) - Path parameters parsed as object
- [headers](/essential/validation/#headers) - HTTP Header, additional information about the request like “Content-Type”.

See [Context](/essential/handler/#context).

## Preview

You can preview the result by looking under the **editor** section.

There should be a tiny navigator on the **top left** of the preview window.

You can use it to switch between path and method to see the response.

You can also click  to edit body, and headers.

## Assignment

Let’s try extracting context parameters:
