Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

fiber

> 编程语言
Free

⚡️ Express inspired web framework written in Go

40.4K stars0 likes3 views
WebsiteGitHub

About

⚡️ Express inspired web framework written in Go

</picture>

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.


</picture>

</picture>

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

   


⚙️ 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:

bash
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:

bash
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.

⚡️ 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
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 to learn more.

🤖 Benchmarks

These tests are performed by TechEmpower. If you want to see all the results, please visit our Wiki.

🎯 Features

  • Robust Routing
  • Serve Static Files
  • Extreme Performance
  • Low Memory footprint
  • API Endpoints
  • Middleware & Next support
  • Rapid server-side programming
  • Template Engines
  • WebSocket Support
  • Socket.io Support
  • Server-Sent Events
  • Rate Limiter
  • And much more, explore Fiber

💡 Philosophy

New gophers that make the switch from Node.js to Go 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, Discord channel 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 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.

Express-style handlers

Fiber also adapts Express-style callbacks that operate on the lightweight fiber.Req and fiber.Res helper interfaces. This lets you port middleware and route handlers from Express-inspired codebases while keeping Fiber's router features:

…

Note: Adapted net/http handlers continue to operate with the standard-library semantics. They don't get access to fiber.Ctx features and incur the overhead of the compatibility layer, so native fiber.Handler callbacks still provide the best performance.

👀 Examples

Listed below are some of the common examples. If you want to see more code examples, please visit our Recipes repository or visit our hosted API documentation.

📖 Basic Routing

…

📖 Route Naming

…

📖 Serving Static Files

…

📖 Middleware & Next

…
📚 Show more code examples

Views Engines

📖 Config 📖 Engines 📖 Render

Fiber defaults to the html/template when no view engine is set.

If you want to execute partials or use a different engine like amber, handlebars, mustache, or pug, etc., check out our Template package that supports multiple view engines.

go
package main

import (
    "log"

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

func main() {
    // Initialize a new Fiber app with Pug template engine
    app := fiber.New(fiber.Config{
        Views: pug.New("./views", ".pug"),
    })

    // Define a route that renders the "home.pug" template
    app.Get("/", func(c fiber.Ctx) error {
        return c.Render("home", fiber.Map{
            "title": "Homepage",
            "year":  1999,
        })
    })

    log.Fatal(app.Listen(":3000"))
}

Grouping Routes into Chains

📖 Group

…

Middleware Logger

📖 Logger

go
package main

import (
    "log"

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

func main() {
    app := fiber.New()

    // Use Logger middleware
    app.Use(logger.New())

    // Define routes
    app.Get("/", func(c fiber.Ctx) error {
        return c.SendString("Hello, Logger!")
    })

    log.Fatal(app.Listen(":3000"))
}

Cross-Origin Resource Sharing (CORS)

📖 CORS

go
package main

import (
    "log"

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

func main() {
    app := fiber.New()

    // Use CORS middleware with default settings
    app.Use(cors.New())

    // Define routes
    app.Get("/", func(c fiber.Ctx) error {
        return c.SendString("CORS enabled!")
    })

    log.Fatal(app.Listen(":3000"))

Issues· 29 open

View all issuesOpen on GitHub
  • #2524

    [Feature]: Add map support to QueryParser

    ✏️ FeatureUpdated Sep 29, 2026
  • #4604

    Consolidate sanitization/normalization helpers and remove double processing

    🧹 Updatesv3Updated Sep 29, 2026
  • #4714

    [Proposal]: raise the default ReadBufferSize and WriteBufferSize to 16 KB

    v3📝 ProposalUpdated Sep 28, 2026
  • #3429

    [Question]: Missing Error Details in Query Parser for Custom Types

    🤔 Question🛠 In ProgressUpdated Sep 22, 2026
  • #4163

    [Proposal]: Fiber official Swagger support

    ✏️ Featurev3📝 ProposalUpdated Sep 11, 2026
  • #4358

    feat: eliminate global mutex contention across storage-backed middleware (limiter, cache, session)

    ✏️ FeatureUpdated Aug 23, 2026
  • #4605

    Align with fasthttp: adopt existing helpers, propose upstream exports and documentation asks

    🧹 Updatesv3Updated Aug 21, 2026
  • #4563

    v4: stop implementing context.Context on Ctx

    Updated Aug 5, 2026
  • #4334

    [Maintenance]: refactor cache handler lock management — replace goto/unlock/relock pattern

    v3Updated Jun 15, 2026
  • #3141

    [Proposal]: Add app.Benchmark method with Context and InMemory Listener

    ✏️ Featurev3Updated Jun 13, 2026

> Tags

Goexpressexpressjsfast

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedDec 4, 2026
Category编程语言
PricingFree

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言