---
title: "Basic Routing"
description: "Basic routing in Hono allows you to map incoming HTTP requests to specific handler functions. By defining paths and HTTP methods, you control how your application responds to different traffic dire..."
last_updated: "2026-07-02T09:15:05.265314+00:00"
canonical_url: "https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/guide/getting-started/basic-routing"
---

Basic routing in Hono allows you to map incoming HTTP requests to specific handler functions. By defining paths and HTTP methods, you control how your application responds to different traffic directed at your server.

Hono uses a `Hono` instance to manage these mappings, providing a simple, chainable API for defining routes.

## Getting Started

To create basic routes, instantiate the `Hono` class and use the method names corresponding to the HTTP verbs (e.g., `get`, `post`, `put`, `delete`).

1. **Import `Hono`:**
   ```typescript
   import { Hono } from 'hono'
   ```
2. **Initialize the application:**
   ```typescript
   const app = new Hono()
   ```
3. **Define a route:**
   ```typescript
   app.get('/hello', (c) => c.text('Hello!'))
   ```

## Supported HTTP Methods

You can define routes for standard HTTP methods. Every method follows the same signature: `app.method(path, handler)`.

| Method | Description |
| :--- | :--- |
| `app.get()` | Handles GET requests |
| `app.post()` | Handles POST requests |
| `app.put()` | Handles PUT requests |
| `app.delete()` | Handles DELETE requests |
| `app.all()` | Matches any HTTP method |

> [!TIP]
> Use `app.all(path, handler)` if you need a single handler to respond to all HTTP methods for a specific path.

## Grouping Routes

When building larger applications, you can organize your routes using `.basePath()` or `.route()`.

### Using .basePath()
This method prefixes all routes defined on that instance with the provided path.
```typescript
const api = new Hono().basePath('/api')

api.get('/users', (c) => c.json({ users: [] })) // GET /api/users
```

### Using .route()
You can nest another `Hono` instance under a specific path, effectively modularizing your codebase.
```typescript
const app = new Hono()
const userApp = new Hono()

userApp.get('/', (c) => c.text('List of users'))

app.route('/users', userApp) // GET /users/
```

## Advanced Routing Options

You can customize how Hono handles paths during instantiation.

```typescript
const app = new Hono({
  strict: false // If false, /hello/ matches /hello
})
```

> [!WARNING]
> By default, `strict` is set to `true`. This means that a route defined as `/hello` will not match `/hello/` (a trailing slash). Ensure your client requests match your defined path strictness.

> [!NOTE]
> Hono automatically uses a `SmartRouter` by default, which switches between high-performance strategies (like Trie or RegExp) to ensure your routes are matched as quickly as possible. You do not need to configure this manually unless you have specific routing requirements.

## Routing Workflow

```mermaid
graph TD
    A[Incoming Request] --> B{Route Matched?}
    B -- Yes --> C[Execute Handler]
    B -- No --> D[Default 404]
    C --> E[Response Sent]
    D --> E
    C -- Error Occurred --> F[Internal Error Handler]
    F --> E
```

## Related

- [Request Handling](https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/guide/core-concepts/request-handling)
- [Response Handling](https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/guide/core-concepts/response-handling)


## Sitemap

See the full [sitemap](https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/llms.txt) for all pages in this wiki.
