DEV Community

Alex Spinov
Alex Spinov

Posted on

Go Fiber Has a Free Express-Inspired Web Framework for Go

Fiber brings Express.js simplicity to Go with zero memory allocation routing. If you know Express, you already know Fiber — at 10x the performance.

Go for Web? Really?

Go's standard library HTTP server is powerful but verbose. Gin simplified things. Fiber simplified things further by matching Express.js API one-to-one.

What You Get for Free

package main

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

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

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

    app.Get("/user/:id", func(c *fiber.Ctx) error {
        id := c.Params("id")
        return c.JSON(fiber.Map{"id": id, "name": "Alice"})
    })

    app.Post("/user", func(c *fiber.Ctx) error {
        user := new(User)
        if err := c.BodyParser(user); err != nil {
            return c.Status(400).JSON(fiber.Map{"error": err.Error()})
        }
        return c.JSON(user)
    })

    app.Listen(":3000")
}
Enter fullscreen mode Exit fullscreen mode

If you've written Express.js — this is instantly familiar.

Built on Fasthttp — the fastest HTTP engine in Go (not net/http)
Zero allocation — routing uses zero heap allocation
Express-like APIapp.Get(), app.Post(), c.JSON(), c.Params()
Middleware ecosystem — CORS, rate limit, logger, recover, cache, session
WebSocket support — built-in
Template engines — HTML, Pug, Mustache, Handlebars

Performance

Requests/second (JSON response):

  • Express.js: ~15,000
  • Fastify: ~60,000
  • Gin (Go): ~150,000
  • Fiber (Go): ~200,000+

Fiber on Fasthttp handles concurrent connections with minimal memory.

Middleware

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

app.Use(logger.New())
app.Use(cors.New())
app.Use(limiter.New(limiter.Config{
    Max: 100,
    Expiration: 1 * time.Minute,
}))
Enter fullscreen mode Exit fullscreen mode

Quick Start

go mod init myapp
go get github.com/gofiber/fiber/v2
Enter fullscreen mode Exit fullscreen mode

If you're a JavaScript developer wanting Go performance — Fiber is the smoothest transition.


Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.

Custom solution? Email spinov001@gmail.com — quote in 2 hours.

Top comments (0)