nuxt-trustup-io-auth
Nuxt module for auth
Quick Setup
- 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
- Add
@deegital/nuxt-trustup-io-auth
to themodules
section ofnuxt.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