Getting Started
How should I structure my application?
How should I structure my application?
There’s no single answer; the ideal structure depends on your application’s scale and team. Fiber makes no assumptions about project layout.Routes and other application logic can live in any files or directories. For inspiration, see:
How can I use live reload?
How can I use live reload?
Air automatically restarts your Go application when source files change, speeding development.To use Air in a Fiber project:As you edit source files, Air detects the changes and restarts the application.A complete example is available in the Fiber Recipes repository.
- Install Air by downloading the appropriate binary for your operating system from the GitHub release page or by building the tool from source.
-
Create a configuration file for Air in your project directory, such as
.air.tomlorair.conf:
- Start your Fiber application with Air:
Error Handling
How do I set up an error handler?
How do I set up an error handler?
To override the default error handler, provide a custom one in the Config when creating a new Fiber instance.We have a dedicated page explaining how error handling works in Fiber, see Error Handling.
How do I handle custom 404 responses?
How do I handle custom 404 responses?
If you’re using v2.32.0 or later, implement a custom error handler as shown above or read more at Error Handling.If you’re using v2.31.0 or earlier, the error handler will not capture 404 errors. Instead, add a middleware function at the very bottom of the stack (below all other functions) to handle a 404 response:
Templates and Rendering
Routing and Networking
Does Fiber support subdomain routing?
Does Fiber support subdomain routing?
Compatibility and Integration
How can I handle conversions between Fiber and net/http?
How can I handle conversions between Fiber and net/http?
Fiber can register common
net/http handlers directly—just pass an http.Handler, http.HandlerFunc, compatible function, or even a native fasthttp.RequestHandler to your routing method.For other interoperability scenarios, the adaptor middleware provides utilities for converting between Fiber and net/http. It allows seamless integration of net/http handlers, middleware, and requests into Fiber applications, and vice versa.For details on how to:- Convert
net/httphandlers to Fiber handlers - Convert Fiber handlers to
net/httphandlers - Convert
fiber.Ctxtohttp.Request
Is Fiber compatible with net/http?
Is Fiber compatible with net/http?
Yes, but with some considerations:Fiber is built on top of fasthttp rather than
net/http for performance reasons. However, Fiber provides:- Adaptor middleware for converting between Fiber and
net/httphandlers - Similar API to Express.js and other web frameworks for easier learning
- Context wrappers that can be converted to
http.Requestandhttp.ResponseWriter
net/http handlers, using native Fiber handlers will provide better performance.Performance and Architecture
Why is Fiber so fast?
Why is Fiber so fast?
Fiber achieves exceptional performance through several design decisions:
- Built on fasthttp: Uses fasthttp instead of
net/http, which is optimized for speed - Zero-allocation router: Custom router designed to minimize memory allocations
- Efficient memory pooling: Reuses objects to reduce garbage collection pressure
- Optimized middleware: Middleware pipeline is designed for minimal overhead
- No reflection in hot paths: Avoids expensive reflection operations in critical code paths
What is zero-allocation routing?
What is zero-allocation routing?
Zero-allocation routing means the router doesn’t allocate new memory for most operations, reducing garbage collection overhead and improving performance.Fiber’s router achieves this by:
- Reusing route parameter buffers
- Using memory pools for common objects
- Avoiding unnecessary string allocations
- Optimizing path matching algorithms
Should I use Fiber for production?
Should I use Fiber for production?
Yes, Fiber is production-ready and used by many companies in production environments.Fiber provides:
- Battle-tested foundation: Built on fasthttp, which is widely used in production
- Active maintenance: Regular updates and security patches
- Large community: Extensive middleware ecosystem and community support
- Proven performance: Excellent benchmarks and real-world performance
- Test thoroughly with your specific use case
- Monitor performance in production
- Follow security best practices
- Keep dependencies updated
Community and Support
Does Fiber have a community chat?
Does Fiber have a community chat?
Yes, we have a Discord server with rooms for every topic.If you have questions or just want to chat, join us via this invite link.

How can I contribute to Fiber?
How can I contribute to Fiber?
We welcome contributions! Here’s how you can help:
- Report bugs: Open an issue on GitHub
- Submit PRs: Fix bugs or add features
- Improve docs: Help improve documentation
- Create middleware: Build and share middleware packages
- Help others: Answer questions on Discord and GitHub
Where can I find examples?
Where can I find examples?
Several resources are available:
Advanced Topics
Can I use Fiber with microservices?
Can I use Fiber with microservices?
Absolutely! Fiber is excellent for microservices due to:
- Low resource footprint: Uses minimal memory and CPU
- Fast startup time: Quickly starts and stops for container environments
- High throughput: Handles many requests efficiently
- Small binary size: Compiles to compact executables
- REST APIs
- gRPC services (with adaptor)
- Event-driven services
- Service mesh components
How do I handle WebSockets?
How do I handle WebSockets?
Fiber supports WebSockets through the WebSocket middleware:See the WebSocket middleware documentation for more details.
Can I run multiple Fiber apps?
Can I run multiple Fiber apps?
Yes, you can run multiple Fiber applications:
- On different ports:
- Using app mounting:
- Subdomain routing (see example above)
Have a question not answered here? Visit our Discord community or open an issue on GitHub.