Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
Getting Started
Providers
Twitter

Twitter/X Provider

Resources

Setup

Callback URL

https://example.com/api/auth/callback/twitter

Environment Variables

AUTH_TWITTER_ID
AUTH_TWITTER_SECRET

Configuration

/auth.ts
import NextAuth from "next-auth"
import Twitter from "next-auth/providers/twitter"
 
export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [Twitter],
})

Notes

  • Auth.js now uses Twitter/X OAuth 2.0 by default. There’s no need to set version anymore.
  • Email is currently not supported by Twitter/X OAuth 2.0.
Auth.js © Balázs Orbán and Team - 2024