This guide demonstrates OAuth setup using Google. Other providers follow the same pattern.
http://localhost:3000/api/auth/callback/google
GOOGLE_CLIENT_ID="your-client-id"
GOOGLE_CLIENT_SECRET="your-client-secret"
server/auth.config.tsimport { defineServerAuth } from '@onmax/nuxt-better-auth/config'
export default defineServerAuth({
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
})
<script setup lang="ts">
definePageMeta({ auth: 'guest' })
const { signIn } = useUserSession()
</script>
<template>
<button
type="button"
@click="signIn.social({ provider: 'google', callbackURL: '/dashboard' })"
>
Continue with Google
</button>
</template>
Better Auth supports 20+ providers (Apple, Discord, Facebook, etc). The pattern is identical:
{PROVIDER}_CLIENT_ID and {PROVIDER}_CLIENT_SECRET to .envserver/auth.config.tssignIn.social({ provider: 'providerId' })