Authentication
/Better Auth
Better Auth
Better Auth provides a complete authentication solution for Open LangGraph Server with support for multiple providers and session management.
Installation
Configuration
Add the required environment variables:
Setup
1. Create Auth Instance
2. Create Auth Routes
3. Mount Routes
Integration with LangGraph
Use Better Auth sessions in your graph workflows by accessing the session data:
Complete Hono Integration
Here's a complete example of integrating Better Auth with Open LangGraph Server:
Middleware Details
The auth middleware function:
- Handles CORS preflight requests (OPTIONS) by allowing them to pass through
- Validates sessions using Better Auth's
getSessionAPI - Returns 401 error for unauthorized requests
- Injects user context into the LangGraph request via
langgraph_context - Makes session data available in your graph workflows through
config.configurable
This middleware is applied to all routes ('/*') to ensure consistent authentication across your entire application.
Accessing Context in Graphs
Built with
Show your support! Star us on GitHub ⭐️