📦gofiber / fiber
← 返回首页
⚡️ Express inspired web framework written in Go
⚖️ MIT#go#golang#fiber#web#fast🌐 gofiber.io📅 创建于 2020-01-16🔄 更新于 2026-10-29

📄 仓库 README

在 GitHub 查看 ↗
来自 GitHub 仓库自述文件 · 版权归原作者所有

Fiber
Codecov

Fiber is an Express inspired web framework built on top of Fasthttp, the fastest HTTP engine for Go. Designed to ease things up for fast development with zero memory allocation and performance in mind.


Official Sponsors

CodeRabbit

Blacksmith

Tool Sponsors - supporting Fiber with free IDE licenses and AI credits

JetBrains   OpenAI   Anthropic


⚙️ Installation

Fiber requires Go version 1.26 or higher to run. If you need to install or upgrade Go, visit the official Go download page. To start setting up your project, create a new directory for your project and navigate into it. Then, initialize your project with Go modules by executing the following command in your terminal:

go mod init github.com/your/repo

To learn more about Go modules and how they work, you can check out the Using Go Modules blog post.

After setting up your project, you can install Fiber with the go get command:

go get -u github.com/gofiber/fiber/v3

This command fetches the Fiber package and adds it to your project's dependencies, allowing you to start building your web applications with Fiber.

🚚 Migrate

Coming from Fiber v2? The Fiber CLI can migrate your project to v3 for you. Install it, then run the migrate command in your project's directory:

go install github.com/gofiber/cli/fiber@latest
fiber migrate --to v3

Review the changes and run your tests afterwards. Run fiber migrate --help to see all options, and see the migration guide for what changed in v3.

⚡️ Quickstart

Getting started with Fiber is easy. Here's a basic example to create a simple web server that responds with "Hello, World 👋!" on the root path. This example demonstrates initializing a new Fiber app, setting up a route, and starting the server.

```go title="Example" package main

import ( "log"

"github.com/gofiber/fiber/v3"

)

func main() { // Initialize a new Fiber app app := fiber.New()

// Define a route for the GET method on the root path '/'
app.Get("/", func(c fiber.Ctx) error {
    // Send a string response to the client
    return c.SendString("Hello, World 👋!")
})

// Start the server on port 3000
log.Fatal(app.Listen(":3000"))

}


This simple server is easy to set up and run. It introduces the core concepts of Fiber: app initialization, route definition, and starting the server. Just run this Go program, and visit `http://localhost:3000` in your browser to see the message.

## Zero Allocation

Fiber is optimized for **high-performance**, meaning values returned from **fiber.Ctx** are **not** immutable by default and **will** be reused across requests. As a rule of thumb, you **must** only use context values within the handler and **must not** keep any references. Once you return from the handler, any values obtained from the context will be reused in future requests. Visit our [documentation](https://docs.gofiber.io/#zero-allocation) to learn more.

## 🤖 Benchmarks

These tests are performed by [TechEmpower](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=plaintext). If you want to see all the results, please visit our [Wiki](https://docs.gofiber.io/extra/benchmarks).

<p float="left" align="middle">
  <img src="https://raw.githubusercontent.com/gofiber/docs/master/static/img/v3/plaintext.png" width="49%">
  <img src="https://raw.githubusercontent.com/gofiber/docs/master/static/img/v3/json.png" width="49%">
</p>

## 🎯 Features

- Robust [Routing](https://docs.gofiber.io/guide/routing)
- Serve [Static Files](https://docs.gofiber.io/api/app#static)
- Extreme [Performance](https://docs.gofiber.io/extra/benchmarks)
- [Low Memory](https://docs.gofiber.io/extra/benchmarks) footprint
- [API Endpoints](https://docs.gofiber.io/api/ctx)
- [Middleware](https://docs.gofiber.io/category/-middleware) & [Next](https://docs.gofiber.io/api/ctx#next) support
- [Rapid](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) server-side programming
- [Template Engines](https://github.com/gofiber/template)
- [WebSocket Support](https://docs.gofiber.io/contrib/websocket)
- [Socket.io Support](https://docs.gofiber.io/contrib/socketio)
- [Server-Sent Events](https://docs.gofiber.io/middleware/sse)
- [Rate Limiter](https://docs.gofiber.io/middleware/limiter)
- And much more, [explore Fiber](https://docs.gofiber.io/)

## 💡 Philosophy

New gophers that make the switch from [Node.js](https://nodejs.org/en/about/) to [Go](https://go.dev/doc/) are dealing with a learning curve before they can start building their web applications or microservices. Fiber, as a **web framework**, was created with the idea of **minimalism** and follows the **UNIX way**, so that new gophers can quickly enter the world of Go with a warm and trusted welcome.

Fiber is **inspired** by Express, the most popular web framework on the Internet. We combined the **ease** of Express and **raw performance** of Go. If you have ever implemented a web application in Node.js (_using Express or similar_), then many methods and principles will seem **very common** to you.

We **listen** to our users in [issues](https://github.com/gofiber/fiber/issues), Discord [channel](https://gofiber.io/discord) _and all over the Internet_ to create a **fast**, **flexible** and **friendly** Go web framework for **any** task, **deadline** and developer **skill**! Just like Express does in the JavaScript world.

## ⚠️ Limitations

- Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber v3 has been tested with Go version 1.26 or higher.
- Fiber automatically adapts common `net/http` handler shapes when you register them on the router, and you can still use the [adaptor middleware](https://docs.gofiber.io/middleware/adaptor/) when you need to bridge entire apps or `net/http` middleware.

### net/http compatibility

Fiber can run side by side with the standard library. The router accepts existing `net/http` handlers directly and even works with native `fasthttp.RequestHandler` callbacks, so you can plug in legacy endpoints without wrapping them manually:

```go
package main

import (
    "log"
    "net/http"

    "github.com/gofiber/fiber/v3"
)

func main() {
    httpHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        if _, err := w.Write([]byte("served by net/http")); err != nil {
            panic(err)
        }
    })

    app := fiber.New()
    app.Get("/", httpHandler)

    // Start the server on port 3000
    log.Fatal(app.Listen(":3000"))
}

When you need to convert entire applications or reuse net/http middleware chains, rely on the adaptor middleware. It converts handlers and middlewares in both directions and even lets you mount a Fiber app in a net/http server.

📈 近 7 天 Star 趋势

每日新增 Star(柱)与累计 Star(线)· 数据来自 GitHub

🏆 排名变化趋势

在各榜单中的排名历史(数字越小越靠前)

📋 历史上榜记录

每次快照的详细数据
日期 榜单 排名 周期新增 总 STAR