GuidesAuth Providers
Twitter (X) Auth
Add Twitter/X OAuth sign-in to your app.
Docs are in beta — content is improving rapidly. Found something missing? Open an issue on GitHub or reach out on Twitter (X).
1. Create a Twitter Developer App
-
Go to the Twitter Developer Portal
-
From side menu click on Apps then Create App
-
Create App:
- App Name, Environment
- Click Create New Client Application
-
Configure:
- Click on the App you just created
- Click Settings
- Type of App: Web App, Automated App or Bot
- Enable (Request email from users*
- Put in App Info
- Callback URI / Redirect URL:
http://localhost:3000/api/auth/callback/twitter(dev)https://yourdomain.com/api/auth/callback/twitter(prod)
- Website URL, Terms URL, Privacy URL, Organization Name, Organization URL
-
Save, then go to Keys and tokens
-
Under OAuth 2.0 Client ID and Client Secret, copy both values
2. Set Environment Variables
# .env.local
TWITTER_CLIENT_ID=your-oauth2-client-id
TWITTER_CLIENT_SECRET=your-oauth2-client-secret3. Enable in Config
In src/appConfig.ts set:
twitter: { enabled: true },4. Test
- Run
pnpm dev - Navigate to
/auth/sign-in - A Sign in with Twitter button will appear
Production Checklist
- Add your production callback URL in the Twitter Developer Portal app settings
- Twitter's free tier may limit OAuth usage — check your plan's rate limits
Troubleshooting
- No email returned — make sure
user.emailscope is enabled in your app's user authentication settings unauthorized_client— ensure you're using OAuth 2.0 credentials (not OAuth 1.0a API keys)- No Twitter button — check
TWITTER_CLIENT_IDandTWITTER_CLIENT_SECRETare set andtwitter.enabledistrue