Skip to main content

The Fiber CLI

ยท 4 min read
Fiber Team
Maintainers

Most Go web frameworks give you a library and send you on your way. Fiber ships a CLI tool that handles the repetitive tasks around development: live reload when files change, project scaffolding from templates, serving static files with one command, and migrating between Fiber versions automatically.

You do not need the CLI to use Fiber. But once you try fiber dev instead of manually restarting your server after every change, you will not go back.

Installationโ€‹

go install github.com/gofiber/cli/fiber@latest

Requires a recent Go version. After installation, fiber is available in your terminal.

fiber dev - Live Reloadโ€‹

The most-used command. It watches your project files and restarts the server whenever something changes:

fiber dev

That is it. Edit a .go file, save, and your server restarts automatically. No external tools like Air or nodemon needed.

Customizing the Watchโ€‹

By default, fiber dev watches .go, .tmpl, .tpl, and .html files. You can adjust this:

# Watch additional file types
fiber dev -e go,tmpl,html,css,js

# Ignore specific directories
fiber dev -D assets,tmp,vendor,node_modules,dist

# Set a delay before restarting (avoid rapid restarts during save-all)
fiber dev -d 2s

# Run commands before each restart
fiber dev --pre-run="go generate ./..."

# Pass arguments to your app
fiber dev -a "-port=8080,-debug=true"

The --pre-run flag is powerful. If your project uses code generation, template compilation, or asset building, those commands run automatically before each restart.

Watch a Specific Targetโ€‹

If your main.go is not in the project root:

fiber dev -t ./cmd/server

fiber new - Project Scaffoldingโ€‹

Generate a new Fiber project from templates:

# Basic project structure
fiber new myapp

# With a custom Go module name
fiber new myapp github.com/yourname/myapp

# Complex project structure with more boilerplate
fiber new myapp -t complex

The basic template gives you a minimal Fiber project: main.go, go.mod, and a simple route. The complex template includes directory structure, configuration, middleware setup, and more.

Custom Templatesโ€‹

You can generate projects from any GitHub repository:

# From a specific GitHub repo
fiber new myapp -t complex -r your-org/your-template

# From any Git URL
fiber new myapp -t complex -r https://gitlab.com/team/fiber-template.git

# SSH-based repo
fiber new myapp -t complex -r [email protected]:team/template.git

This lets your team maintain a standard project template and generate new services from it in seconds.

fiber serve - Static File Serverโ€‹

Need to serve static files quickly? Maybe you are developing a frontend, reviewing a build output, or hosting documentation:

# Serve the current directory on :3000
fiber serve

# Serve a specific directory on a custom port
fiber serve --dir ./dist --addr :8080

# Enable directory browsing
fiber serve --browse

# Enable compression and CORS
fiber serve --compress --cors

# Serve with TLS
fiber serve --cert ./cert.pem --key ./key.pem

This is a full-featured static file server with caching, compression, CORS, health checks, byte-range requests, and optional TLS - all without writing a single line of Go code.

All serve optionsโ€‹

FlagDefaultDescription
--addr:3000Listen address
--dir.Directory to serve
--browsefalseEnable directory listing
--compressfalseEnable gzip/brotli compression
--corsfalseEnable CORS headers
--cache10sCache duration
--indexindex.htmlIndex file names
--cert / --key-TLS certificate and key
--preforkfalseEnable prefork mode
--downloadfalseForce file downloads
--rangefalseEnable byte-range requests

fiber migrate - Version Migrationโ€‹

Upgrading Fiber versions usually means finding breaking changes, updating import paths, and adjusting API calls. The CLI automates this:

# Migrate to Fiber v3
fiber migrate --to 3.0.0

# Also refresh third-party modules (contrib, storage, template)
fiber migrate --to 3.0.0 --third-party contrib,storage,template

# Verbose output for debugging
fiber migrate --to 3.0.0 --verbose

The migration tool updates your go.mod, adjusts import paths, and runs go mod tidy automatically. It covers the mechanical work of migration so you can focus on the API changes that need manual attention.

fiber upgrade - Self-Updateโ€‹

Keep the CLI itself up to date:

fiber upgrade

Checks for the latest release and updates in place.

fiber versionโ€‹

Check your CLI and Fiber versions:

fiber version

Shows both the CLI version and the latest available version, so you know when an update is available.

The Development Workflowโ€‹

A typical development session with the Fiber CLI:

# Scaffold a new project
fiber new my-api github.com/myorg/my-api
cd my-api

# Start developing with live reload
fiber dev

# In another terminal, serve the frontend
fiber serve --dir ./frontend/dist --addr :8080 --cors

The CLI handles the infrastructure. You write the code.

Internal Referencesโ€‹