Skip to content

Update README.md #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://www.propelauth.com?ref=github" target="_blank" align="center">
<img src="https://propelauth-logos.s3.us-west-2.amazonaws.com/logo-only.png" width="100">
<img src="https://www.propelauth.com/imgs/lockup.svg" width="200">
</a>
</p>

Expand All @@ -17,6 +17,60 @@ Your frontend gets a beautiful, safe, and customizable login screen. Your backen
- Full reference this library is [here](https://docs.propelauth.com/reference/frontend-apis/js)
- Getting started guides for PropelAuth are [here](https://docs.propelauth.com/)

## Installation and Usage

```bash
npm install @propelauth/javascript
```

and then you can import it:

```js
import { createClient } from "@propelauth/javascript";
```

Alternatively, you can use a CDN:

```html
<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:

```html
<script>
PropelAuth.createClient({...});
</script>
```

## Using the Javascript library

You'll create a client using the [createClient](#create-client) 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).


### createClient

Creates an authentication client which manages your user's [access token](https://docs.propelauth.com/guides-and-examples/guides/access-tokens), 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).

```js
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,
});
```

## Questions?

Feel free to reach out at support@propelauth.com