# @userfront/core

> Userfront core JS library

Latest version **1.1.2** (published 2025-04-25) · 0 weekly downloads

## Install

```sh
npm install @userfront/core
pnpm add @userfront/core
yarn add @userfront/core
bun add @userfront/core
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2025-04-25 |
| First published | 2020-10-28 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 (+30 in 2 direct dependencies) |
| Install scripts | no |
| Author | Userfront |
| Maintainers | tyrw, steve(at)uf |
| Keywords | userfront, auth, authentication, authorization, access, control, multi-tenancy |

## Links

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

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) 1.8.3
- [js-cookie](https://npm.io/package/js-cookie.md) 2.2.1

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2025-04-25
- 1.0.1 (alpha) — 2024-09-19
- 0.6.5-beta.1 (beta) — 2023-07-26
- 1.1.1-canary.1 — 2025-03-21
- 1.1.1 — 2024-10-10
- 1.1.0 — 2024-10-10
- 1.0.0 — 2024-07-26
- 0.6.8 — 2023-12-04
- 0.6.7 — 2023-11-03
- 0.6.6 — 2023-08-25
- 0.6.5 — 2023-07-27
- 0.6.4 — 2023-07-13
- 0.6.3 — 2023-06-30
- 0.6.2 — 2023-06-29
- 0.6.1 — 2023-06-16
- … 86 more at https://npm.io/package/@userfront/core/versions

## 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):

```sh
npm install @userfront/core --save
```

Import and initialize the library:

```js
import Userfront from "@userfront/core";

Userfront.init("demo1234");
```

## Examples

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

// Send a login link
Userfront.sendLoginLink("jane@example.com");

// 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: "jane@example.com",
 *    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`

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