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

VK Provider

Resources

Setup

Callback URL

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

Environment Variables

AUTH_VK_ID
AUTH_VK_SECRET

Configuration

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

Notes

  • By default the provider uses 5.126 version of the API. See https://vk.com/dev/versions for more info. If you want to use a different version, you can pass it to provider’s options object:
./auth.ts
const apiVersion = "5.126"
 
export const { handlers, auth, signin, signout } = NextAuth({
  providers: [
    Vk({
      accessTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
      requestTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
      authorizationUrl: `https://oauth.vk.com/authorize?response_type=code&v=${apiVersion}`,
      profileUrl: `https://api.vk.com/method/users.get?fields=photo_100&v=${apiVersion}`,
    }),
  ],
})
Auth.js © Balázs Orbán and Team - 2024