Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clerk/clerk-js

Package Overview
Dependencies
Maintainers
7
Versions
3200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clerk/clerk-js

Clerk JS library

  • 4.47.1-staging.0ff85c6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31K
decreased by-6.72%
Maintainers
7
Weekly downloads
 
Created
Source


@clerk/clerk-js

Chat on Discord Clerk documentation Follow on Twitter

Changelog · Report a Bug · Request a Feature · Ask a Question


Overview

ClerkJS is our foundational JavaScript library for building user management and authentication. It enables you to register, sign in, verify and manage users for your application using highly customizable flows.

Getting Started

Installation

There are two ways you can include ClerkJS in your project. You can either import the ClerkJS npm module or load ClerkJS with a script tag.

Install ClerkJS as ES module

npm install @clerk/clerk-js

Once you have installed the package, you will need to import the ClerkJS object constructor into your code and pass it your Frontend API as a parameter.

import Clerk from '@clerk/clerk-js';

const clerkFrontendApi = 'pk_[publishable_key]';
const clerk = new Clerk(clerkFrontendApi);
await clerk.load({
  // Set load options here...
});

Install ClerkJS as script

ClerkJS can be loaded from a <script /> tag with the source from your Frontend API URL.

Add the following script to your site's <body> element:

<script>
  // Get this URL and Publishable Key from the Clerk Dashboard
  const clerkFrontendApi = 'pk_[publishable_key]';
  const frontendApi = '[your-domain].clerk.accounts.dev';
  const version = '@latest'; // Set to appropriate version

  // Creates asynchronous script
  const script = document.createElement('script');
  script.setAttribute('data-clerk-frontend-api', frontendApi);
  script.setAttribute('data-clerk-publishable-key', clerkFrontendApi);
  script.async = true;
  script.src = `https://${frontendApi}/npm/@clerk/clerk-js${version}/dist/clerk.browser.js`;

  // Adds listener to initialize ClerkJS after it's loaded
  script.addEventListener('load', async function () {
    await window.Clerk.load({
      // Set load options here...
    });
  });
  document.body.appendChild(script);
</script>

Build

To build the package locally with Webpack, run:

npm run build

Usage

<h1>Hello Clerk!</h1>

<button
  id="sign-in-button"
  onclick="Clerk.openSignIn()"
>
  Sign In
</button>
<div id="user-button"></div>

<script>
  async function loadClerk() {
    const userButton = document.getElementById('user-button');
    const signInButton = document.getElementById('sign-in-button');

    await window.Clerk.load();

    if (Clerk.user) {
      Clerk.mountUserButton(userButton);
      signInButton.hidden = true;
    }
  }
  // [...] Installation code
</script>

For further details and examples, please refer to our Documentation.

Support

You can get in touch with us in any of the following ways:

Contributing

We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines.

Security

@clerk/clerk-js follows good practices of security, but 100% security cannot be assured.

@clerk/clerk-js is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the MIT license.

See LICENSE for more information.

Keywords

FAQs

Package last updated on 15 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc