explaingit

go-chi/chi

📈 Trending22,117GoAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Lightweight HTTP router for Go that organizes web API routes cleanly using composable middleware, with no external dependencies.

Mindmap

mindmap
  root((chi))
    What it does
      Routes HTTP requests
      Organizes endpoints
      Stacks middleware
    Key features
      Grouped routes
      Sub-routers
      Patricia Radix trie
    Use cases
      REST APIs
      Microservices
      Admin sections
    Tech stack
      Go standard library
      No dependencies
    Audience
      Go developers
      API builders

Things people build with this

USE CASE 1

Build REST APIs in Go with clean, organized URL routing and grouped endpoints.

USE CASE 2

Add middleware like logging, timeouts, and authentication to specific routes or entire route groups.

USE CASE 3

Create admin sections and sub-routers for different parts of your application.

USE CASE 4

Generate routing documentation automatically from your code structure.

Tech stack

GoHTTPPatricia Radix trie

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

Chi is a lightweight router for building web APIs and HTTP services in the Go programming language. A router is the part of a web server that decides which function handles which web address, for example, sending requests for "/articles" to one handler and "/users" to another. Chi solves the problem of organizing these routes cleanly as a project grows larger and more complex. The core idea behind chi is composability, meaning you build your API by stacking small, reusable pieces together. These pieces are called middlewares (pronounced "middle-wear"), and they are functions that run before or after your main handler, handling things like logging requests, setting timeouts, or checking if someone is allowed to access a page. Chi lets you attach these middlewares to the entire app, to a group of related routes, or to a single endpoint individually. Under the hood, chi uses a data structure called a Patricia Radix trie to match incoming URLs to the right handler quickly. Despite this technical underpinning, chi works entirely with Go's built-in standard library, there are no external dependencies, which keeps it small (less than 1,000 lines of code) and fully compatible with any existing Go HTTP tools. You would use chi when you are building a REST API in Go and want clean URL routing, grouped routes (like all /articles/* endpoints together), sub-routers for sections like /admin, and middleware support, without pulling in a large external framework. It also includes optional tools for auto-generating routing documentation from your code. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
Show me how to set up chi to route GET /articles and POST /articles to different handlers.
Prompt 2
How do I add logging middleware to all routes under /admin/* in chi?
Prompt 3
Create a chi router with grouped routes for /users and /products, each with their own sub-handlers.
Prompt 4
How do I use chi's middleware to add request timeouts and authentication checks?
Prompt 5
Set up a chi sub-router for an /api/v1 namespace with multiple endpoints.
Open on GitHub → Explain another repo

Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.