What are Providers?
Providers are concrete implementations of ports that connect your application to external services. They follow the hexagonal architecture pattern, making your code more testable and maintainable.Available Providers
Database
Drizzle + Turso
SQLite database with Drizzle ORM and Turso hosting
Caching
Redis
In-memory caching with Redis
Authentication
Better Auth
Full-featured authentication solution
Background Jobs
Inngest
Reliable background job processing
Rate Limiting
Upstash Rate Limit
Distributed rate limiting
Using Providers
1. Install the Provider
2. Configure the Provider
3. Register with Ports
4. Use in Your Application
Creating Custom Providers
You can create custom providers for services not yet supported:Provider Patterns
Environment Configuration
Lazy Initialization
Testing with Mock Providers
Best Practices
Use environment variables
Use environment variables
Store API keys and connection strings in environment variables, never in code.
Initialize providers once
Initialize providers once
Create provider instances once at startup and reuse them across requests.
Handle connection errors
Handle connection errors
Implement proper error handling and reconnection logic for external services.
Close connections gracefully
Close connections gracefully
Clean up connections on shutdown to prevent resource leaks.
Use providers in tests
Use providers in tests
Create mock providers for unit tests to avoid external dependencies.