Skip to content

Latest commit

 

History

History

README.md

MongoDB Database Adapter Example

Next.js example using the Integrate MongoDB adapter to persist OAuth tokens in MongoDB.

Setup

Requires a running MongoDB instance (local Docker, Atlas, etc.).

bun install
cp .env.example .env
# Add INTEGRATE_API_KEY, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, MONGODB_URI

bun dev

Open http://localhost:3000, connect GitHub, and list repos. Tokens are stored in the provider_tokens collection.

Key files

  • src/lib/db.ts — MongoDB client
  • src/lib/integrate.tsmongodbAdapter + getSessionContext

This example uses a fixed DEMO_USER_ID for session context. Wire getSessionContext to your auth library in production.