docs/migrate/from-fiber/page.md
{% answer %}
Migrating from Fiber to GoFr also moves you from fasthttp to net/http. This is usually a simplification — net/http-compatible libraries become directly usable, and middleware translation is straightforward. Handlers go from func(c *fiber.Ctx) error to func(c *gofr.Context) (any, error).
{% /answer %}
{% callout title="Migrating with an AI assistant?" %} Hand https://gofr.dev/AGENTS.md to your coding assistant (Claude Code, Cursor, Codex, Aider). It contains the framework conventions, routing/binding/datasource patterns, and per-framework cheat-sheets so the assistant can translate handlers without you re-explaining GoFr. {% /callout %}
Fiber:
app.Get("/users/:id", func(c *fiber.Ctx) error {
id := c.Params("id")
user, err := db.GetUser(id)
if err != nil {
return c.Status(404).JSON(fiber.Map{"error": err.Error()})
}
return c.JSON(user)
})
GoFr:
app.GET("/users/{id}", func(c *gofr.Context) (any, error) {
id := c.PathParam("id")
user, err := db.GetUser(id)
return user, err
})
| Operation | Fiber | GoFr |
|---|---|---|
| Path param | c.Params("id") | c.PathParam("id") |
| Query param | c.Query("q") | c.Param("q") |
| Body parse | c.BodyParser(&input) | c.Bind(&input) |
Fiber middleware is fiber.Handler. GoFr middleware is the standard net/http func(http.Handler) http.Handler. Most third-party net/http middleware works directly with GoFr.
This is where the migration pays off most. In Fiber:
otelfiber, configure exporter, propagate spans manually for DB calls.fiber/v2/middleware/monitor or expose Prometheus separately.database/sql or driver of choice; instrument it yourself.In GoFr:
c.SQL, c.Redis, c.Mongo, etc.) are auto-instrumented with span correlation.If your Fiber service used adaptor.HTTPHandler to wrap net/http middleware, those adapters become unnecessary in GoFr — net/http is native. Drop them.
net/http. If you depend on valyala/fasthttp-specific packages, plan to swap each for a net/http equivalent.c.Locals has no direct equivalent. *gofr.Context does not expose Set / Get methods for per-request locals. Either pass values through Go closures, or — since *gofr.Context embeds context.Context — use context.WithValue(c, key, value) and retrieve with c.Value(key).adaptor.HTTPHandler wrappers you used to call net/http middleware from Fiber are now unnecessary — drop them.http.ResponseWriter from a custom middleware.A typical Fiber-based REST service migrates in 1–2 engineering days. The biggest unknown is whether any of your dependencies are fasthttp-only.
{% faq %}
{% faq-item question="Does GoFr support Fiber's request lifecycle features (Locals, etc.)?" %}
There is no c.Locals-style per-request locals API on *gofr.Context. Pass values through closures, or use the standard context.Context mechanism — *gofr.Context embeds context.Context, so context.WithValue(c, key, value) and c.Value(key) work.
{% /faq-item %}
{% faq-item question="Can I keep using fasthttp libraries with GoFr?" %}
No — GoFr is net/http-based. Libraries written for fasthttp won't work directly. Most have net/http-equivalent alternatives.
{% /faq-item %}
{% /faq %}