@bitinflow/nuxt-oauth
Nuxt module for OAuth2 authentication
Features
- 📦 OAuth2 authentication
- 📦 Supports only one OAuth2 provider
- 📦 Supports only implicit flow
Quick Setup
- Add
@bitinflow/nuxt-oauth
dependency to your project
pnpm add -D @bitinflow/nuxt-oauth
yarn add --dev @bitinflow/nuxt-oauth
npm install --save-dev @bitinflow/nuxt-oauth
- Add
@bitinflow/nuxt-oauth
to the modules
section of nuxt.config.ts
and disable ssr
.
Or alternatively disable ssr
via routeRules
, only for pages where auth
or guest
middlewares are needed. Typically account section and login page.
export default defineNuxtConfig({
modules: [
'@bitinflow/nuxt-oauth'
],
ssr: false,
routeRules: {
'/account/**': { ssr: false },
'/auth/**': { ssr: false }
},
oauth: {
redirect: {
login: '/login',
logout: '/',
callback: '/login',
home: '/home'
},
endpoints: {
authorization: 'https://example.com/v1/oauth/authorization',
userInfo: `https://example.com/api/users/me`,
logout: 'https://example.com/oauth/logout'
},
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
scope: ['user:read']
},
})
That's it! You can now use @bitinflow/nuxt-oauth in your Nuxt app ✨
Development
npm install
npm run dev:prepare
npm run dev
npm run dev:build
npm run lint
npm run test
npm run test:watch
npm run release