@deegital/nuxt-trustup-io-auth
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

nuxt-trustup-io-auth

npm version npm downloads License Nuxt

Nuxt module for auth

Quick Setup

  1. Add @deegital/nuxt-trustup-io-auth dependency to your project
# Using pnpm
pnpm add -D @deegital/nuxt-trustup-io-auth

# Using yarn
yarn add --dev @deegital/nuxt-trustup-io-auth

# Using npm
npm install --save-dev @deegital/nuxt-trustup-io-auth
  1. Add @deegital/nuxt-trustup-io-auth to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    '@deegital/nuxt-trustup-io-auth'
  ],
  trustupIoAuth: {}
})

Usage/Examples

NUXT_PUBLIC_AUTH_TRUSTUP_IO_URL=https://auth.trustup.io
export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      authTrustupIoUrl: "",
    },
  },
  ...
  trustupIoAuth: {
    localStorageKey: "auth_token", // the name of the key for the token, 'auth_token by default'
  },
  ...

In your app.vue you should use the layout to have the loader and hide if not authenticated

  <template>
  <div>
    <h1>App</h1>
    <div>
      <NuxtLayout name="auth-layout">
        <NuxtPage />
      </NuxtLayout>
    </div>
  </div>
</template>

If you want to display the user informations you can use the composable useAuth()

    const auth = useAuth();

    console.log(auth.user);

That's it! You can now use nuxt-trustup-io-auth in your Nuxt app ✨

Development

Bootstrap module

Find and replace all on all files (CMD+SHIFT+F):

  - nuxt-trustup-io-auth // nuxt-trustup-io-toasteo
  - Nuxt module for auth // Our notification package for nuxt.
  - trustupIoAuth // trustupIoToasteo
  - @deegital // @deegital
  - git@github.com:deegitalbe/nuxt-trustup-io-auth.git // git@github.com:deegitalbe/nuxt-trustup-io-toasteo.git

Start bootstrap script

./cli bootstrap

Available commands

# Install dependencies
./cli yarn install

# Generate playground
./cli yarn generate

# Start project
./cli start

# Stop project
./cli stop

# Restart project
./cli restart

# Build the playground for production
./cli yarn dev:build

# Run ESLint
./cli yarn lint

# Run Vitest
./cli yarn test
./cli yarn test:watch

# Validate your package (running linter & typecript validation)
./cli yarn validate

# Build the package for publication
./cli yarn build

# Release new version
npm version patch

References

Nuxt module development reference

Readme

Keywords

none

Package Sidebar

Install

npm i @deegital/nuxt-trustup-io-auth

Weekly Downloads

9

Version

1.3.1

License

MIT

Unpacked Size

28.6 kB

Total Files

69

Last publish

Collaborators

  • axel_dev_trustup
  • fhusquinet
  • henrotaym