vanling / nuxt-auth

πŸ” Nuxt user authentication and sessions via NextAuth.js. nuxt-auth wraps NextAuth.js to offer the reliability & convenience of a 12k star library to the nuxt 3 ecosystem with a native developer experience (DX)

Home Page:https://sidebase.io/nuxt-auth/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nuxt-auth demo page

πŸ” nuxt-auth

npm version npm downloads GitHub stars License Follow us on Twitter Join our Discord

nuxt-auth is a feature-packed, open-source authentication module for Nuxt 3 applications.

Quick Start

npm i -D @sidebase/nuxt-auth

Then visit the Quick Start documentation to setup the module.

Features

nuxt-auth wraps NextAuth.js to offer the reliability & convenience of a 12k star library to the nuxt 3 ecosystem with a native developer experience (DX). Features of nuxt-auth include:

  • βœ”οΈ Authentication providers:
    • βœ”οΈ OAuth (e.g., Github, Google, Twitter, Azure, ...)
    • βœ”οΈ Custom OAuth (write it yourself)
    • βœ”οΈ Credentials (password + username)
    • βœ”οΈ Email Magic URLs
  • βœ”οΈ Isomorphic / Universal Auth Composable useSession supports:
    • actions: getSession, getCsrfToken, getProviders, signIn, signOut
    • getters: status, data, lastRefreshedAt
    • full typescript support for all methods and property
  • βœ”οΈ Application-side middleware protection
  • βœ”οΈ Server-side middleware and endpoint protection
  • βœ”οΈ Advanced features for session life-cycle management:
    • Refresh the session periodically
    • Refresh the session on tab-refocus
    • One time session fetch on page load, afterwards for specific actions (e.g., on navigation)
    • 🚧 Session broadcasting between tabs (see #70)
  • βœ”οΈ Persistent sessions across requests
  • βœ”οΈ REST API:
    • GET /signin,
    • POST /signin/:provider,
    • GET/POST /callback/:provider,
    • GET /signout,
    • POST /signout,
    • GET /session,
    • GET /csrf,
    • GET /providers

Demo Page

Visit the nuxt-auth demo page here: nuxt-auth demo page

You can find the demo source-code here.

Development

  • Run npm run dev:prepare to generate type stubs.
  • Use npm run dev to start the module playground in development mode.
  • Run npm run lint to run eslint
  • Run npm run types to run typescheck via tsc
  • Run npm publish --access public to publish (bump version before)

Module Playground

This module also has it's own playground:

> git clone https://github.com/sidebase/nuxt-auth

> cd nuxt-auth

# **OPEN THE `~/playground/server/api/auth/[...].ts` and configure your own auth-provider

> npm i

> npm run dev:prepare

> npm run dev

# -> open http://localhost:3000

About

πŸ” Nuxt user authentication and sessions via NextAuth.js. nuxt-auth wraps NextAuth.js to offer the reliability & convenience of a 12k star library to the nuxt 3 ecosystem with a native developer experience (DX)

https://sidebase.io/nuxt-auth/

License:MIT License


Languages

Language:TypeScript 88.9%Language:Vue 11.1%