# vuex-auth0

> Vuex Module for Auth0 Universal Login

Latest version **1.0.0** (published 2020-12-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install vuex-auth0
pnpm add vuex-auth0
yarn add vuex-auth0
bun add vuex-auth0
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-29 |
| First published | 2020-12-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michoel Samuels |
| Maintainers | analyzeplatypus |

## Links

- npm: https://www.npmjs.com/package/vuex-auth0
- npm.io page: https://npm.io/package/vuex-auth0

## Dependencies (1)

- [@auth0/auth0-spa-js](https://npm.io/package/@auth0/auth0-spa-js.md) ^1.11.0

## Recent versions

- 1.0.0 (latest) — 2020-12-29

## README

# Auth0-Vuex

A Vuex module for easily logging in with the Auth0 SPA SDK.

This one-liner:
```js
store.dispatch("auth0/login");
```

* Silently retrieves auth tokens for authenticated users
* Redirects logged-out user to Auth0 Universal Login
* Retrieves Auth0 query params from the URL (if present) to complete Auth0 login flow


Full example:

```js
// Make sure your environment has these vars set:
// process.env.VUE_APP_AUTH0_DOMAIN
// process.env.VUE_APP_AUTH0_CLIENT_ID

import Vuex from 'vuex';
import auth0Vuex from 'auth0-vuex';

Vue.use(Vuex)

const store = {
  modules: {
    auth0: auth0Vuex
  }
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

store.dispatch("auth0/login");
```

## API

### Actions

* `auth0/login`: Attempts to silently log the user in; otherwise redirects the user to the Auth0 Universal Login portal
* `auth0/logout`: Logs the user out and redirects them to the Auth0 Universal Login portal

### Getters

* `isLoggedIn` Boolean. `watch` this to detect when auth tokens have been successfully retrieved.
* `currentAuthHeaders` Bearer token for for calling your secured APIs. (From `idToken._raw`)
* `user` Object. Currently logged in user's details
* `client` A reference to the underlying `Auth0Client` instance.

## Tips

This library complements Hasura really nicely.

---
_Source: https://npm.io/package/vuex-auth0 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
