A library for managing authentication in the browser, backed by PropelAuth.
PropelAuth makes it easy to add authentication and authorization to your B2B/multi-tenant application.
Your frontend gets a beautiful, safe, and customizable login screen. Your backend gets easy authorization with just a few lines of code. You get an easy-to-use dashboard to config and manage everything.
npm install @propelauth/javascriptand then you can import it:
import { createClient } from "@propelauth/javascript";Alternatively, you can use a CDN:
<script
src="https://www.unpkg.com/@propelauth/javascript/dist/javascript.min.js"
crossorigin="anonymous"
></script>then a global PropelAuth object will be created, and you can call createClient from it:
<script>
PropelAuth.createClient({...});
</script>You'll create a client using the createClient function, and then you can use the client to get information about the current user.
You can also enabled background token refresh, which will automatically refresh the user's information periodically and on key events (e.g. user switches tabs, reconnects to the internet, etc).
Creates an authentication client which manages your user's access token, fetches user information, and provides other useful authentication functions.
The client also refreshes auth information when a user switches focus to your tab or reconnects (if they were offline).
const authClient = createClient({
// The base URL where your authentication pages are hosted.
// You can find this under the Frontend Integration section for your project.
authUrl: "https://auth.yourdomain.com",
// If true, periodically refresh the access token in the background.
// This helps ensure you always have a valid token ready to go. Default true.
enableBackgroundTokenRefresh: true,
});Feel free to reach out at support@propelauth.com