Skip to main content

Installation

Get started with Fiber by installing the framework and setting up your development environment.

Prerequisites

Fiber requires Go version 1.25 or higher to run.
If you need to install or upgrade Go, visit the official Go download page. Verify your Go installation:
go version
You should see output similar to:
go version go1.25.0 darwin/amd64

Installation steps

1

Create a new project directory

Create a new directory for your Fiber project and navigate into it:
mkdir myapp
cd myapp
2

Initialize Go modules

Initialize your project with Go modules by running:
go mod init github.com/your/repo
Replace github.com/your/repo with your actual module path. This creates a go.mod file that tracks your project’s dependencies.
To learn more about Go modules and how they work, check out the Using Go Modules blog post.
3

Install Fiber

Install Fiber using 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 in go.mod.
4

Create your first application

Create a new file called main.go:
main.go
package main

import (
    "log"

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

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

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

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

Run your application

Start your Fiber application:
go run main.go
Visit http://localhost:3000 in your browser, and you should see “Hello, World 👋!”.

Project structure

After installation, your project structure should look like this:
myapp/
├── go.mod
├── go.sum
└── main.go
  • go.mod: Defines your module path and lists dependencies
  • go.sum: Contains checksums for dependency verification
  • main.go: Your application entry point

Installing additional packages

Fiber has a rich ecosystem of middleware and utilities. Here are some commonly used packages:
# Logger middleware
go get -u github.com/gofiber/fiber/v3/middleware/logger

# CORS middleware
go get -u github.com/gofiber/fiber/v3/middleware/cors

# Compression middleware
go get -u github.com/gofiber/fiber/v3/middleware/compress

Version compatibility

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.25 or higher.
Check the installed Fiber version in your code:
package main

import (
    "fmt"
    "github.com/gofiber/fiber/v3"
)

func main() {
    fmt.Println("Fiber version:", fiber.Version)
    // Output: Fiber version: 3.1.0
}

Development tools

For a better development experience, consider installing these tools:

Air (Live reload)

Air provides live reloading for Go applications:
go install github.com/air-verse/air@latest
Create a .air.toml configuration file and run:
air

golangci-lint (Code linting)

Install the comprehensive Go linter:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
Run the linter:
golangci-lint run

Troubleshooting

Module not found

If you encounter “module not found” errors, ensure you’ve run:
go mod tidy
This command adds missing dependencies and removes unused ones.

Import errors

Make sure you’re importing the correct Fiber version:
// Correct (v3)
import "github.com/gofiber/fiber/v3"

// Incorrect (v2)
import "github.com/gofiber/fiber/v2"

Port already in use

If port 3000 is already in use, specify a different port:
log.Fatal(app.Listen(":8080"))

Next steps

Quick start guide

Build your first complete Fiber application

Routing

Learn about Fiber’s powerful routing system

Middleware

Explore built-in and custom middleware

API reference

Dive into the complete API documentation

Build docs developers (and LLMs) love