explaingit

go-chi/chi

Analysis updated 2026-06-21

22,117GoAudience · developerComplexity · 2/5Setup · easy

TLDR

chi is a lightweight Go HTTP router for building REST APIs, it gives you clean URL routing, middleware support, and grouped sub-routers with zero external dependencies and full compatibility with Go's standard net/http library.

Mindmap

mindmap
  root((chi))
    What it does
      HTTP request routing
      URL parameter extraction
      Middleware composition
    How it works
      Patricia radix trie
      Built on net/http
      Context-based params
    Use cases
      REST APIs
      Grouped admin routes
      Large Go services
    Audience
      Go developers
      API builders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a REST API in Go with clean URL routing including path parameters like /articles/{id} and regex constraints

USE CASE 2

Add middleware for logging, authentication, and timeouts to your Go web service using chi's composable middleware stack

USE CASE 3

Organize a large Go API into sub-routers for sections like /api/v1 and /admin, each with its own middleware

USE CASE 4

Replace Go's bare net/http routing with a structured, maintainable router that works with any existing net/http middleware

What is it built with?

Go

How does it compare?

go-chi/chiredis/go-redisfilosottile/age
Stars22,11722,07422,198
LanguageGoGoGo
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Single go get install with zero external dependencies, works with all existing net/http middleware out of the box.

In plain English

chi is a small library for the Go programming language that helps you build HTTP services, the server-side code that responds to web requests. Its specific job is routing: when a request comes in for, say, GET /articles/123, the router decides which Go function should handle it. The README describes chi as lightweight, idiomatic, and composable, with a particular focus on writing large REST API services that stay maintainable as a project grows. The way it works is built on top of Go's standard net/http package and the context package introduced in Go 1.7. You create a router with chi.NewRouter, then attach handlers to URL patterns like r.Get("/", handler) or r.Post("/articles", createArticle). URL parameters such as {articleID} can be extracted from the path, and you can use a regular expression inside the pattern to constrain what matches. Middleware (functions that run before or after handlers, used for things like logging, request IDs, panic recovery, or timeouts) is attached with r.Use, and inline middleware can be added with r.With for a single endpoint. Routes can be grouped or mounted as sub-routers, so an /admin section can have its own router with its own middleware stack, which keeps large APIs organised. Internally, route matching is based on a Patricia radix trie data structure, which keeps lookups fast. You would use chi when you are writing a Go web service or REST API and want more structure than net/http provides on its own, without taking on a heavier framework. The README highlights that the core router is around 1000 lines of code, has no external dependencies beyond the Go standard library, is fully compatible with net/http (so any middleware written for that ecosystem works with chi), and that it has been used in production at companies like Pressly, Cloudflare, Heroku, and 99Designs. Optional companion packages cover render helpers and a docgen tool that auto-generates routing documentation in JSON or Markdown from the source. Installation is a single go get of github.com/go-chi/chi/v5.

Copy-paste prompts

Prompt 1
Show me how to set up a chi router in Go with routes for GET /articles, GET /articles/{id}, POST /articles, and DELETE /articles/{id}.
Prompt 2
How do I add middleware to a chi router for request logging, panic recovery, and a 30-second timeout on all routes?
Prompt 3
I want to protect my /admin routes in chi with an authentication middleware while leaving /public routes open, show me how to group routes with different middleware stacks.
Prompt 4
How do I extract a URL path parameter like {articleID} from the request context in a chi handler?
Prompt 5
Show me how to mount a separate chi sub-router for an /api/v2 section with its own middleware inside a larger chi router.

Frequently asked questions

What is chi?

chi is a lightweight Go HTTP router for building REST APIs, it gives you clean URL routing, middleware support, and grouped sub-routers with zero external dependencies and full compatibility with Go's standard net/http library.

What language is chi written in?

Mainly Go. The stack also includes Go.

How hard is chi to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is chi for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub go-chi on gitmyhub

Verify against the repo before relying on details.