An Express-inspired web framework written in Go.

Fiber is a Go web framework built on top of Fasthttp, the fastest HTTP engine for Go. It's designed to ease things up for fast development with zero memory allocation and performance in mind.
package main

import (
    "log"

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

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

    app.Get("/", func (c *fiber.Ctx) error {
        return c.SendString("Hello, World!")
    })

    log.Fatal(app.Listen(":3000"))
}
http://localhost:3000
Hello, World!
Get Started
...or scroll to learn more.

Robust Routing

Setting up routes for your application has never been so easy! The Express-like route definitions are easy to understand and work with.

app.Get("/", func (c *fiber.Ctx) error {
    return c.SendString("GET request")
})

app.Get("/:param", func (c *fiber.Ctx) error {
    return c.SendString("param: " + c.Params("param"))
})

app.Post("/", func (c *fiber.Ctx) error {
    return c.SendString("POST request")
})

Serve Static Files

Serve your static HTML, CSS, and JavaScript files with ease by defining static routes. You can also serve the contents of multiple directories on the same route!

app.Static("/", "./public")

// => http://localhost:3000/hello.html
// => http://localhost:3000/js/jquery.js
// => http://localhost:3000/css/style.css

// serve from multiple directories
app.Static("/", "./files")

Extreme Performance

Since Fiber is built on top of Fasthttp, your apps will enjoy unmatching performance! Don't believe us? Here's a benchmark that proves how Fiber shines compared to other frameworks:

Benchmark graph

API-ready

Are you building an API server? We've got you covered! Fiber is the perfect choice for building REST APIs in Go. Receiving and sending data is fast and easy!

app.Get("/api/posts", func (c *fiber.Ctx) error {
    posts := getPosts() // your logic
    if len(posts) == 0 {
        return c.Status(404).JSON(&fiber.Map{
            "success": false,
            "error":   "There are no posts!",
        })
    }
    return c.JSON(&fiber.Map{
        "success": true,
        "posts":   posts,
    })
})

Flexible Middleware Support

Choose from a number of already existing middleware or create your own! Use them to verify and manipulate certain requests in your app before they reach your controller.

package main

import (
    "log"
    
    "github.com/gofiber/fiber/v2"
    "github.com/gofiber/fiber/v2/middleware/cors"
)

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

    app.Use(cors.New())

    app.Use(func (c *fiber.Ctx) error {
        if c.Is("json") {
            return c.Next()
        }
        return c.SendString("Only JSON allowed!")
    })

    app.Get("/", func(c *fiber.Ctx) error {
        return c.JSON(fiber.Map{
            "message": "Hello World",
        })
    })

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

Low Memory Footprint

Fiber's low memory footprint allows you to implement features without worrying too much about how much memory your application will use. This allows you to focus on your application and its business logic, rather than technical particularities.

Rapid Programming

Take your idea and turn it into reality in no time! Thanks to the well-designed and easy-to-learn API, you can develop your application in record speed (especially if you're coming from an Express.js background).

Template Engines

Want to use a different template engine in your Fiber app? Fear no more! Fiber supports multiple template engines, such as Handlebars and Pug, thanks to the template middleware.

package main

import (
    "log"

    "github.com/gofiber/fiber/v2"
    "github.com/gofiber/template/html"
)

func main() {
    app := fiber.New(fiber.Config{
        Views: html.New("./views", ".html"),
    })

    app.Get("/", func(c *fiber.Ctx) error {
      return c.Render("index", fiber.Map{
         "Title": "Hello, World!",
      })
    })

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

WebSocket Support

Use the power of WebSockets in your Fiber app! Build fast interactive user experiences with performance and scalability guaranteed.

app.Get("/ws", websocket.New(func(c *websocket.Conn) {
  // Websocket logic
  for {
    mtype, msg, err := c.ReadMessage()
    if err != nil {
      break
    }
    log.Printf("Read: %s", msg)

    err = c.WriteMessage(mtype, msg)
    if err != nil {
      break
    }
  }
  log.Println("Error:", err)
}))

Rate Limiter

With Fiber, limiting repeated requests to public APIs and endpoints is very simple. No more abusive requests!

package main

import (
    "log"
    "time"

    "github.com/gofiber/fiber/v2"
    "github.com/gofiber/fiber/v2/middleware/limiter"
)

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

  // 3 requests per 10 seconds max
  app.Use(limiter.New(limiter.Config{
      Expiration: 10 * time.Second,
      Max:      3,
  }))

  // ...

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

Help & Support

Join a community of developers who are passionate about Fiber. Ask questions, share your creation, and have fun in our Discord server.

Translated To 18 Languages

EnglishRussianSpanishJapanesePortugueseChineseTaiwaneseGermanDutchKoreanFrenchTurkishIndonesianHebrewArabicPersianItalianCentral Kurdish

Media

Official Sponsors

Airbrake - Error Monitoring

...and much more!