Details
Category: HTTP Routers & Frameworks
Github: https://github.com/gofiber/fiber
Website: https://gofiber.io/
Published: May 2025
Tool Description
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.
β οΈ Attention
Fiber v3 is currently in beta and under active development. While it offers exciting new features, please note that it may not be stable for production use. We recommend sticking to the latest stable release (v2.x) for mission-critical applications. If you choose to use v3, be prepared for potential bugs and breaking changes. Always check the official documentation and release notes for updates and proceed with caution. Happy coding! π
βοΈ Installation
Fiber requires Go version 1.23
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.
β‘οΈ 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.
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 re-used 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 re-used 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
π‘ 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
π 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
package main
import (
"fmt"
"log"
"github.com/gofiber/fiber/v3"
)
func main() {
app := fiber.New()
// GET /api/register
app.Get("/api/*", func(c fiber.Ctx) error {
msg := fmt.Sprintf("β %s", c.Params("*"))
return c.SendString(msg) // => β register
})
// GET /flights/LAX-SFO
app.Get("/flights/:from-:to", func(c fiber.Ctx) error {
msg := fmt.Sprintf("πΈ From: %s, To: %s", c.Params("from"), c.Params("to"))
return c.SendString(msg) // => πΈ From: LAX, To: SFO
})
// GET /dictionary.txt
app.Get("/:file.:ext", func(c fiber.Ctx) error {
msg := fmt.Sprintf("π %s.%s", c.Params("file"), c.Params("ext"))
return c.SendString(msg) // => π dictionary.txt
})
// GET /john/75
app.Get("/:name/:age/:gender?", func(c fiber.Ctx) error {
msg := fmt.Sprintf("π΄ %s is %s years old", c.Params("name"), c.Params("age"))
return c.SendString(msg) // => π΄ john is 75 years old
})
// GET /john
app.Get("/:name", func(c fiber.Ctx) error {
msg := fmt.Sprintf("Hello, %s π!", c.Params("name"))
return c.SendString(msg) // => Hello john π!
})
log.Fatal(app.Listen(":3000"))
}
π Route Naming
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/gofiber/fiber/v3"
)
func main() {
app := fiber.New()
app.Get("/api/*", func(c fiber.Ctx) error {
msg := fmt.Sprintf("β %s", c.Params("*"))
return c.SendString(msg) // => β register
}).Name("api")
route := app.GetRoute("api")
data, _ := json.MarshalIndent(route, "", " ")
fmt.Println(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }
log.Fatal(app.Listen(":3000"))
}
π Serving Static Files
package main
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/static"
)
func main() {
app := fiber.New()
// Serve static files from the "./public" directory
app.Get("/*", static.New("./public"))
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Get("/prefix*", static.New("./public"))
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
// Serve a single file for any unmatched routes
app.Get("*", static.New("./public/index.html"))
// => http://localhost:3000/any/path/shows/index.html
log.Fatal(app.Listen(":3000"))
}
π Middleware & Next
package main
import (
"fmt"
"log"
"github.com/gofiber/fiber/v3"
)
func main() {
app := fiber.New()
// Middleware that matches any route
app.Use(func(c fiber.Ctx) error {
fmt.Println("π₯ First handler")
return c.Next()
})
// Middleware that matches all routes starting with /api
app.Use("/api", func(c fiber.Ctx) error {
fmt.Println("π₯ Second handler")
return c.Next()
})
// GET /api/list
app.Get("/api/list", func(c fiber.Ctx) error {
fmt.Println("π₯ Last handler")
return c.SendString("Hello, World π!")
})
log.Fatal(app.Listen(":3000"))
}
𧬠Internal Middleware
Here is a list of middleware that are included within the Fiber framework.
𧬠External Middleware
List of externally hosted middleware modules and maintained by the Fiber team.
πΆοΈ Awesome List
For more articles, middlewares, examples, or tools, check our awesome list.
π Contribute
If you want to say Thank You and/or support the active development of Fiber
:
π» Development
To ensure your contributions are ready for a Pull Request, please use the following Makefile
commands. These tools help maintain code quality and consistency.
Run these commands to ensure your code adheres to project standards and best practices.
β Supporters
Fiber is an open-source project that runs on donations to pay the bills, e.g., our domain name, GitBook, Netlify, and serverless hosting. If you want to support Fiber, you can β buy a coffee here.
π» Code Contributors
βοΈ Stargazers
π§Ύ License
Copyright (c) 2019-present Fenny and Contributors. Fiber
is free and open-source software licensed under the MIT License. Official logo was created by Vic ShΓ³stak and distributed under Creative Commons license (CC BY-SA 4.0 International).