Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/go-chi/chi/llms.txt

Use this file to discover all available pages before exploring further.

chi is a small, fast, and composable HTTP router for Go. Built on a Patricia Radix trie, it is 100% compatible with the standard net/http library and ships with zero external dependencies. Whether you’re building a small microservice or a large REST API, chi scales with your project.

Quickstart

Build your first chi HTTP service in under five minutes with a working example.

Installation

Add chi to your Go project using go get and go modules.

Routing Overview

Learn how chi’s radix trie router works, URL patterns, and route groups.

Middleware

Explore chi’s composable middleware stack and 25+ built-in handlers.

Why chi?

chi was designed to make large REST API services maintainable as they grow. It brings together the best of the Go standard library with a clean, expressive routing API.

Zero Dependencies

Only the Go standard library — no external packages, no version conflicts.

net/http Compatible

Any middleware or handler compatible with net/http works with chi out of the box.

Composable

Build modular services with route groups, sub-routers, and middleware stacks.

Context-Aware

URL parameters and request-scoped values flow through Go’s context.Context.

Fast

Patricia Radix trie routing with minimal allocations per request.

Production-Ready

In use at Cloudflare, Heroku, 99Designs, and many others.

Get started in three steps

1

Install chi

Add chi v5 to your Go module:
go get github.com/go-chi/chi/v5
2

Create a router

main.go
package main

import (
    "net/http"

    "github.com/go-chi/chi/v5"
    "github.com/go-chi/chi/v5/middleware"
)

func main() {
    r := chi.NewRouter()
    r.Use(middleware.Logger)
    r.Use(middleware.Recoverer)

    r.Get("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello, chi!"))
    })

    http.ListenAndServe(":3000", r)
}
3

Run your service

go run main.go
Your service is live at http://localhost:3000.

Explore the docs

Core Concepts

Understand URL patterns, named parameters, wildcards, and route matching.

Built-in Middleware

Logger, Recoverer, RequestID, Timeout, Compress, and 20+ more handlers.

REST API Guide

Build a complete REST API with sub-routers, middleware, and context values.

API Reference

Full reference for the Router interface, Mux, and all public functions.

Ecosystem

CORS, JWT auth, rate limiting, host routing, and more from the go-chi org.

Testing

Test chi handlers and middleware with Go’s standard testing package.

Build docs developers (and LLMs) love