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

Reddit Provider

Resources

Setup

Callback URL

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

Environment Variables

AUTH_REDDIT_ID
AUTH_REDDIT_SECRET

Configuration

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

Notes

  • Reddit requires authorization every time you go through their page.
  • Allows one callback URL per Client ID / Client Secret.
  • This Provider template only has a one hour access token to it and only has the “identity” scope. If you want to get a refresh token as well you must set these authorization params:
./auth.ts
export const { handlers, auth, signin, signout } = NextAuth({
  providers: [
    RedditProvider({
      clientId: process.env.REDDIT_CLIENT_ID,
      clientSecret: process.env.REDDIT_CLIENT_SECRET,
      authorization: {
        params: {
          duration: "permanent",
        },
      },
    }),
  ],
})
Auth.js © Balázs Orbán and Team - 2024