Add Strava sign-in
Users authenticate with their Strava accounts in a Next.js application.
Auth.js · Const
Strava is a built-in Auth.js OAuth provider. Add it to the providers list and supply credentials through AUTH_STRAVA_ID and AUTH_STRAVA_SECRET or explicit provider options.
The Strava provider is a built-in OAuth integration. Add it to the Auth.js providers list; Auth.js can obtain its client credentials from the provider-specific environment variables, then use Strava's callback endpoint to complete sign-in.
function default<P extends StravaProfile>(options: OAuthUserConfig<P>): OAuthConfig<P>| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<P> | Configuration options for the Strava OAuth provider. |
OAuthConfig<P>
import NextAuth from "next-auth"
import Strava from "next-auth/providers/strava"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Strava],
})Registers Strava as an OAuth provider using the inferred AUTH_STRAVA_ID and AUTH_STRAVA_SECRET environment variables.
Users authenticate with their Strava accounts in a Next.js application.
A deployment stores provider credentials outside source code.
An application needs provider-specific profile typing or OAuth overrides.
Strava is enabled by adding the built-in Strava provider to the Auth.js providers array. In a Next.js application, the provider can be imported from next-auth/providers/strava and passed as Strava.
Follow-up: How are credentials supplied without passing options? Auth.js infers them from AUTH_STRAVA_ID and AUTH_STRAVA_SECRET.
The provider's callback URL is https://example.com/api/auth/callback/strava for a Next.js deployment. The hostname must be replaced with the application's real origin and the URL configured with Strava.
Follow-up: What changes for another supported framework? Use that framework's callback path shown in the provider setup documentation rather than the Next.js path.
The provider factory accepts OAuthUserConfig<P> and returns OAuthConfig<P>, where P extends StravaProfile. StravaProfile includes firstname, lastname, id, and profile fields.
Follow-up: When would you provide an explicit generic profile type? Use one when extending or narrowing the profile shape consumed by the provider configuration.
StravaProfileOAuthConfigOAuthUserConfigconfiguring a built-in OAuth provider