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

@userfront/core

v1.1.1

Published

Userfront core JS library

Downloads

2,396

Readme

Userfront Core JS library

The Userfront Core JavaScript library is intended for use in frontend applications.

The Core library can be used for the following:

  • Tokens: read the user's access token to send to your backend
  • User info: information about the currently logged in user
  • Authentication: signup, login, logout, and password reset tasks; these are useful for building custom forms and auth flows.

Docs

Full docs can be found in the Userfront guide:

https://userfront.com/docs/js.html

Setup

Install by npm (or yarn):

npm install @userfront/core --save

Import and initialize the library:

import Userfront from "@userfront/core";

Userfront.init("demo1234");

Examples

// Import and initialize Userfront core JS
import Userfront from "@userfront/core";
Userfront.init("demo1234");

// Send a login link
Userfront.sendLoginLink("[email protected]");

// Read the access token
Userfront.tokens.accessToken;

// => "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJtb2RlIjoidGVzdCIsImlzQ29uZmlybWVkIjp0cnVlLCJ1c2VySWQiOjEsInVzZXJVdWlkIjoiZDAwNTlmN2UtYzU0OS00NmYzLWEzYTMtOGEwNDY0MDkzZmMyIiwidGVuYW50SWQiOiJwOW55OGJkaiIsInNlc3Npb25JZCI6IjRlZjBlMjdjLTI1NDAtNDIzOS05YTJiLWRkZjgyZjE3YmExYiIsImF1dGhvcml6YXRpb24iOnsicDlueThiZGoiOnsidGVuYW50SWQiOiJwOW55OGJkaiIsIm5hbWUiOiJVc2VyZnJvbnQiLCJyb2xlcyI6WyJhZG1pbiJdLCJwZXJtaXNzaW9ucyI6W119fSwiaWF0IjoxNjE3MTQ4MDY3LCJleHAiOjE2MTk3NDAwNjd9.gYz4wxPHLY6PNp8KPEyIjLZ8QzG3-NFJGPitginuLaU"

// Log the user out
Userfront.logout();

// Access the user's information
Userfront.user;

/** =>
 * {
 *    email: "[email protected]",
 *    phoneNumber: "+15558675309",
 *    name: "Jane Example",
 *    image: "https://res.cloudinary.com/component/image/upload/avatars/avatar-plain-9.png",
 *    data: {},
 *    username: "jane-example",
 *    isEmailConfirmed: true,
 *    isPhoneNumberConfirmed: false,
 *    confirmedEmailAt: "2020-01-01T00:00:00.000Z",
 *    confirmedPhoneNumberAt: "2020-01-01T00:00:00.000Z",
 *    isMfaRequired: false,
 *    createdAt: "2020-01-01T00:00:00.000Z",
 *    updatedAt: "2020-01-01T00:00:00.000Z",
 *    mode: "test",
 *    tenantId: "demo1234",
 *    userId: 1,
 *    userUuid: "d6f0f045-f6ea-4262-8724-dfc0b77e7dc9",
 * }
 */

Development

Building

  • npm build: build all library files

The build commands are split into two parts. build and build:beta both run these commands, which do not need to be run separately:

  • npm build:standard: build the standard library files:
    • ESM module build/userfront-core.module.js
    • CJS module build/userfront-core.js
    • UMD module build/userfront-core.umd.js
    • Module with bundled dependencies, for import from CDN: build/userfront-core.modern.mjs