Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

ceigh/nuxt-userbase-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nuxt-userbase-module

User authentication and data storage in Nuxt with Userbase.

npm npm bundle size

Setup

  1. Add nuxt-userbase-module dev dependency to your project
yarn add nuxt-userbase-module

or

npm install nuxt-userbase-module
  1. Add nuxt-userbase-module to the buildModules section of nuxt.config.js.

  2. Add appId to the userbase section. Take it here.

export default {
  buildModules: [
    'nuxt-userbase-module'
  ],
  userbase: {
    appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
  }
}

Usage

After setup, $userbase object were injected to vue instances, nuxt context and vuex store.

Example

You can call it like:

// middleware/example.js
export default async function ({ $userbase }) {
  const session = await $userbase.init()
  console.log(session)

  // or

  const user = await $userbase.signUp({
    username: 'test',
    password: 'test12345678'
  })
  console.log(user)
}

Learn more about context

Methods

This module fully complies with the Userbase SDK.

You can use methods directly from SDK.

This module is also fully typed with typescript in accordance with the SDK.

TypeScript

If you are a Nuxt TypeScript user, you need to add declarations to your .d.ts file for the module to work correctly.

License

MIT License

Copyright © Artjom Löbsack