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

sveltekit-auth0-js

v0.0.17

Published

If you are in need of authentication and you love Auth0 as much as I do, You've found the right package!

Downloads

43

Readme

Authentication - Sveltekit & Auth0

If you are in need of authentication and you love Auth0 as much as I do, You've found the right package!

Authentication can be one of the most frustrating parts of our creation process as developers and hopefully you find this as simple to use and save time.

The initial reason for creating this was because of issues I had when creating the auth components, mounting everything in __layout.svelte file and then being able to place buttons in the Navbar.svelte component. I had issues and this seemed to do everything I desired.

Enjoy what you do and prosper at it!

Follow the below instructions and you'll be up and running with Auth0 authentication in minutes.

I use TailwindCSS so it setup with that in mind and if you do not, it will work just fine.

Create Sveltekit Project

Visit the Docs Getting Started.

# create a new project in the current directory
npm init svelte

# create a new project in my-app
npm init svelte my-app

# create a new project in the current directory
pnpm create svelte

# create a new project in the current directory
pnpm create svelte my-app

Developing

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

# Using pnpm
pnpm dev

# or start the server and open the app in a new browser tab
pnpm dev -- --open

Building

To create a production version of your app:

# using npm
npm run build

# using pnpm
pnpm build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

Installing 'sveltekit-auth0-js'

Visit NPM sveltekit-auth0-js.

# Using npm
npm i sveltekit-auth0-js

# Using pnpm
pnpm i sveltekit-auth0-js

Create or Edit .env file

VITE_AUTH0_DOMAIN = <your-auth0-domain>
VITE_AUTH0_CLIENT_ID = <your-auth0-client-id>
VITE_LOGIN_REDIRECT_URL = "/somewhere"
VITE_LOGOUT_REDIRECT_URL = "/somewhere-else"

Create authStore in your project

./src/lib/stores/authStore.js (or .ts)

Add below code to store

import { writable, derived } from "svelte/store";

export const isAuthenticated = writable(false);
export const user = writable({});
export const popupOpen = writable(false);
export const error = writable();
Get Auth0 User Info once Logged in
<script>
    import { user } from "/src/lib/stores/authStore";
 </script>

<pre>{JSON.stringify($user, null, 2)}</pre>
Component Settings

Insert this into your Navbar component or anywhere else you need it to be.

<script>
    import SveltekitAuth0 from "sveltekit-auth0-js/Sveltekit-Auth0.svelte";
</script>

<SveltekitAuth0
    hideBtnIcon={false}
    btn_login_text=""
    btn_logout_text=""
    imgSrcLogin="/feather/log-in.svg"
    imgSrcLogout="/feather/log-out.svg"
    iconSize="w-5"
    _class="m-2 btn btn-ghost uppercase btn-primary text-sm"
/>