npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dopry/svelte-auth0

v2.0.0

Published

Svelte Auth0 Component Library

Downloads

26

Readme

svelte-auth0

An Auth0 Component for Svelte.

Try out the demo

Getting Started

Setup an Auth0 Account. Get the domain client_id from the Default App.

npm install @dopry/svelte-auth0

App.svelte

<script>
import {
  Auth0Context,
  Auth0LoginButton,
  Auth0LogoutButton,
  authError,
  authToken,
  idToken,
  isAuthenticated,
  isLoading,
  login,
  logout,
  userInfo,
} from '@dopry/svelte-auth0';
</script>

<Auth0Context domain="dev-hvw40i79.auth0.com" client_id="aOijZt2ug6Ovgzp0HXdF23B6zxwA6PaP">
  <Auth0LoginButton class="btn">Login</Auth0LoginButton>
  <Auth0LogoutButton class="btn">Logout</Auth0LogoutButton>
  <pre>isLoading: {$isLoading}</pre>
  <pre>isAuthenticated: {$isAuthenticated}</pre>
  <pre>authToken: {$authToken}</pre>
  <pre>idToken: {$idToken}</pre>
  <pre>userInfo: {JSON.stringify($userInfo, null, 2)}</pre>
  <pre>authError: {$authError}</pre>
</Auth0Context>

Docs

Components

  • Auth0Context - component to initiate the Auth0 client. You only need one instance in your DOM tree at the root

    Attributes:

    • domain - Auth0 domain
    • client_id - Auth0 ClientId
    • audience - The default audience to be used for requesting API access
    • callback_url - override the default url that Auth0 will redirect to after login. default: window.location.href
    • logout_url - override the default url that Auth0 will redirect to after logout. default: window.location.href
  • Auth0LoginButton - log out the current context

    Attributes:

    • preserve_route - tell the callback handler to return to the current url after login. default: true
    • callback_url - override the context callback_url
  • Auth0LogoutButton - log in the current context

    Attributes:

    • logout_url - override the context logout_url

Functions

  • login(auth0Promise, preseveRoute = true, callback_url = null) - begin a user login.
  • logout(auth0Promise, logout_url = null) - logout a user.
  • refreshToken(auth0Promise) - function to refresh a token.

Stores

  • isLoading - if true auth0 is still loading.
  • isAuthenticated - true if user is currently authenticated
  • authToken - api token
  • userInfo - the currently logged in user's info from Auth0
  • authError - the last authentication error.

Constants

  • AUTH0_CONTEXT_CALLBACK_URL,
  • AUTH0_CONTEXT_CLIENT_PROMISE - key for the Auth0 client in setContext/getContext.
  • AUTH0_CONTEXT_LOGOUT_URL,

Release

use semver npm publish npm run showcase:build npm run showcase:publish