Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Const

Wikimedia

Auth.js includes a built-in Wikimedia OAuth provider. Configure its client credentials, register the framework-specific callback URL, and add Wikimedia to the Auth.js providers list.

How it works

Wikimedia is a built-in OAuth provider for Auth.js. Import its provider definition, add it to the providers array, set the required environment variables, and register the matching callback URL with Wikimedia.

Syntax

Wikimedia

Key points

  • The provider reads its client credentials from AUTH_WIKIMEDIA_ID and AUTH_WIKIMEDIA_SECRET.
  • A Next.js deployment should register the callback URL with the /api/auth/callback/wikimedia path.
  • Create an OAuth 2.0 consumer in Wikimedia's registration flow to obtain the client ID and secret.
  • The integration can be used with Wikimedia projects beyond Wikipedia.
  • The documentation explicitly lists Wikipedia, Wikidata, Wikibooks, and Wiktionary as supported projects.

Common mistakes

  • A newly registered Wikimedia OAuth consumer initially supports testing only with the account that registered it.
  • Leave the consumer-wide restriction option disabled so the provider can be used by other accounts.
  • Choose the smallest practical OAuth scope unless the application needs Wikimedia content access or user actions.

Example: Configure Wikimedia with Next.js

import NextAuth from "next-auth"
import Wikimedia from "next-auth/providers/wikimedia"

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [Wikimedia],
})

Register the built-in Wikimedia provider in the Auth.js configuration, then use its exported handlers and authentication helpers.

When to use it

Wikimedia-based sign-in

Let users sign in with an existing Wikimedia account without implementing OAuth endpoints manually.

Multi-project Wikimedia access

Authenticate users across Wikimedia sites such as Wikipedia and Wikidata.

Minimal-permission authentication

Request identity verification only when the application needs login but no page access or user actions.

Interview questions

QHow do you add Wikimedia authentication to a Next.js Auth.js configuration?

Import the built-in Wikimedia provider and include it in Auth.js's providers array. The page's Next.js example uses Wikimedia directly rather than passing custom OAuth endpoints.

Follow-up: How does the callback route get determined? Auth.js uses the provider identifier in the callback path, so the Next.js callback is /api/auth/callback/wikimedia.

QWhich environment variables and callback URL are required?

Set AUTH_WIKIMEDIA_ID and AUTH_WIKIMEDIA_SECRET, then register the corresponding callback URL with Wikimedia. For Next.js, the documented callback format is https://example.com/api/auth/callback/wikimedia.

Follow-up: What must change for another Auth.js integration? Use that framework's callback format; the page shows non-Next.js examples without the /api segment.

QIs this provider limited to Wikipedia?

Wikimedia supports multiple projects, including Wikipedia, Wikidata, Wikibooks, and Wiktionary. The provider therefore represents Wikimedia OAuth access across those projects rather than only one site.

Follow-up: What permission choice is appropriate for sign-in only? Select the identity-verification-only scope unless page reading or user actions are required.

  • OAuth providers
  • Configuring an OAuth provider
  • Auth.js providers

Source: Wikimedia Provider. Checked 2026-10-15.