go-chi/chi
Developer ToolsA lightweight net/http-compatible Go router for building maintainable REST APIs and HTTP services of any size.
What it does
chi is a small router for Go HTTP services that stays fully compatible with the standard net/http interface. It targets REST API backends that need to stay organized as they grow: route groups, sub-router mounting, inline middleware and named URL parameters let you split request handling into small layers without leaving the standard library ecosystem.
The core router is roughly 1000 LOC and has no external dependencies. Routing uses a Patricia radix trie, request-scoped values travel through Go's context, and any net/http-compatible middleware from the wider ecosystem can be plugged in. Optional packages add a middleware suite, response rendering (render) and route documentation generation (docgen).
Quick start
You need a Go toolchain with module support. In your own module, install the v5 package:
go get -u github.com/go-chi/chi/v5
Then create a router, attach the middleware you want, register routes and hand the router to http.ListenAndServe:
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.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("welcome"))
})
http.ListenAndServe(":3000", r)
}
After running it, GET http://localhost:3000/ returns welcome. The example above matches the README's minimal example basic setup. For nested resources, regexp parameters, sub-routers and mounting, read the examples directory, particularly the REST example and its generated routes.json and routes.md.
Middleware and client IP
The bundled middleware package covers logging, panic recovery, timeouts, compression, throttling, request IDs, basic auth, profiling and route deprecation/sunset headers. Middleware are plain func(http.Handler) http.Handler, so third-party net/http middleware works unchanged.
One migration point matters in practice: the legacy RealIP middleware is deprecated because it is vulnerable to IP spoofing and mutates r.RemoteAddr. Instead, choose exactly one ClientIPFrom* middleware that matches your deployment: ClientIPFromRemoteAddr for direct internet exposure, ClientIPFromHeader behind nginx, Cloudflare or Apache, ClientIPFromXFF with trusted CIDRs, or ClientIPFromXFFTrustedProxies for a fixed proxy count. Read the result with GetClientIP or GetClientIPAddr. See the ClientIP selection guide for the deployment table and an example.
Constraints
- chi is designed around
net/http, so handlers and middleware must follow that standard interface; there is no separate framework-specific handler model. - The router is v5 with Go modules, so imports use
github.com/go-chi/chi/v5. - The benchmark results in the README date from November 2020 on Go 1.15.5; they are historical measurements, not a current performance guarantee.
- The project is MIT licensed, with no external dependencies in the core router.
HotRepo's take
chi's only recorded HotRepo snapshot is the Go weekly list for 2026-12-04, where it added 101 stars and reached 9th position in that language list. With no all-language daily ranking or longer star series on record, that single snapshot supports the fact of continued weekly attention but not a trend judgment. For readers, the more durable signal is the project's long history since 2015 and its position as a stable, standard-library-aligned routing layer rather than a fast-moving framework.
Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.
Hacker News
You might also like
- gin-gonic/ginA high-performance Go HTTP framework for building REST APIs, web apps and microservices with routing and middleware.
- hyperium/hyperA low-level Rust HTTP/1 and HTTP/2 library for building async clients and servers on Tokio.
- encode/httpxA full-featured Python HTTP client with sync/async APIs, HTTP/2 and a built-in CLI.
- apache/dubboAn Apache RPC and microservice framework for Java developers building service discovery, traffic management, and observability.
- apache/camelAn integration framework for routing, transforming and moving data between databases, APIs, brokers and cloud services with 350+ connectors.