An Auth0 Component for Svelte.
Setup an Auth0 Account. Get the domain client_id from the Default App.
npm install @dopry/svelte-auth0
<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>
Auth0Context - component to initiate the Auth0 client. You only need one instance in your DOM tree at the root
Attributes:
Auth0LoginButton - log out the current context
Attributes:
Auth0LogoutButton - log in the current context
Attributes:
use semver npm publish npm run showcase:build npm run showcase:publish