This template provides a simple, ready-to-use authentication server as a starting point for your app. Build your own reliable auth server while maintaining full ownership of your data without proprietary restrictions.
- 📧 Email and password login and registration
- 🩺 Healthcheck endpoint
- 📚 OpenAPI plugin enabled
- 💾 Session storage in Redis
- ⚡ Built with Hono.js for lightning-fast performance
- 📦 Compiles to a single Bun binary for easy deployment
Required environment variables:
REDIS_URL
- Connection string for RedisDATABASE_URL
- Connection string for your databaseBETTER_AUTH_SECRET
- Secret key for encryption and security
- 🔄 I strongly encourage FORKING THIS REPO and modifying the config to suit your needs, add other providers, email sending, etc.
- 🗄️ You can use the same DB for your app and this auth server, just be careful with the migrations. This enables you to directly interact with the users and auth tables from your main application.
- 🔌 You can use the endpoints directly or use better-auth on the client side and set the base URL in the config file (highly recommended).
- 📚 For complete documentation, visit Better Auth Docs.
(If you aren't hosting on Railway or aren't using the Railpack builder you can safely delete the railpack.json
file)
- Clone or fork this repository
- Set up the required environment variables
- Install the dependencies with
bun install
- Run the server with
bun run dev
(development) orbun run build
(production) - Connect your application
GET /health
- Check the health of the serverGET /api/auth/reference
- Scalar docs for all of the OpenAPI endpointsGET /api/auth/sign-out
- Logout a userPOST /api/auth/sign-up/email
- Register a new user
{
"name": "",
"email": "",
"password": "",
"callbackURL": ""
}
POST /api/auth/sign-in/email
- Login a user
{
"email": "",
"password": "",
"callbackURL": "",
"rememberMe": ""
}
- Admin panel