# @afroze9/solid-auth0

> A wrapper on top of auth0-spa-js for solidjs.

Latest version **0.2.0** (published 2023-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @afroze9/solid-auth0
pnpm add @afroze9/solid-auth0
yarn add @afroze9/solid-auth0
bun add @afroze9/solid-auth0
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2023-04-06 |
| First published | 2023-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 31 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Afroze Amjad |
| Maintainers | afroze9 |
| Keywords | auth0, solidjs |

## Links

- npm: https://www.npmjs.com/package/@afroze9/solid-auth0
- Repository: https://github.com/afroze9/solid-auth0
- Homepage: https://github.com/afroze9/solid-auth0#readme
- Issues: https://github.com/afroze9/solid-auth0/issues
- npm.io page: https://npm.io/package/@afroze9/solid-auth0

## Dependencies (2)

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

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2023-04-06
- 0.1.1 — 2023-04-03
- 0.1.0 — 2023-04-03

## README

# SolidJS Auth0 Wrapper

A SolidJS implementation for Auth0 using the package `@auth0/auth0-spa-js`. This work is based on top of the library created by [@rturnq](https://github.com/rturnq/solid-auth0) (which hasn't been updated in a few years).

# Getting Started

## Installation

### NPM

```
npm i @afroze9/solid-auth0
```

### PNPM

```
pnpm add @afroze9/solid-auth0
```

### Yarn

```
npm add @afroze9/solid-auth0
```

## Usage

### At the root of your app

Note: Please ensure you have an SPA setup in Auth0 to configure the context.

```tsx
import { Auth0 } from '@afroze9/solid-auth0';

const App: Component = () => {
  return (
    <Auth0
      domain="_auth0_domain_"
      clientId="_client_id_"
      audience="_api_audience_"
      logoutRedirectUri={`${window.location.origin}/`}
      loginRedirectUri={`${window.location.origin}/`}
      scope="_scopes_"
    >
      <AppComponent />
    </Auth0>
  );
};
```

### Elsewhere in the app

```tsx
import { Auth0State, useAuth0 } from '@afroze9/solid-auth0';

const TopNav: Component = () => {
  const auth0: Auth0State<User> | undefined = useAuth0();

  return <div>{auth0?.isAuthenticated() ? <div>Logout</div> : <div>Login</div>}</div>;
};
```

### To secure a route

```tsx
import { Protected } from '@afroze9/solid-auth0';

const MyPage: Component = () => {
  return <div>This is a secure route</div>;
};

// You can pass any component to onRedirecting
export default () => {
  <Protected onRedirecting={<div>Redirecting...</div>}>
    <MyPage />
  </Protected>;
};
```

# Notes

Currently the wrapper only supports a few underlying functions/properties from the original `@auth0/auth0-spa-js` package. Future plan is to add more functionality.

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