Skip to content

Commit e39ea60

Browse files
committed
Update README.md
1 parent 8d5e4e9 commit e39ea60

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<a href="https://www.propelauth.com?ref=github" target="_blank" align="center">
3-
<img src="https://propelauth-logos.s3.us-west-2.amazonaws.com/logo-only.png" width="100">
3+
<img src="https://www.propelauth.com/imgs/lockup.svg" width="200">
44
</a>
55
</p>
66

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

20+
## Installation and Usage
21+
22+
```bash
23+
npm install @propelauth/javascript
24+
```
25+
26+
and then you can import it:
27+
28+
```js
29+
import { createClient } from "@propelauth/javascript";
30+
```
31+
32+
Alternatively, you can use a CDN:
33+
34+
```html
35+
<script
36+
src="https://www.unpkg.com/@propelauth/javascript@2.0.11/dist/javascript.min.js"
37+
integrity="sha384-FENNH2f7QuQvkZJBL7jebLr0OtYKgTA2iq+C5g3VXXX7SBwWmeMMoc+pBBtcn76G"
38+
crossorigin="anonymous"></script>
39+
```
40+
41+
then a global PropelAuth object will be created, and you can call createClient from it:
42+
43+
```html
44+
<script>
45+
PropelAuth.createClient({...});
46+
</script>
47+
```
48+
49+
## Using the Javascript library
50+
51+
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.
52+
53+
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).
54+
55+
56+
### createClient
57+
58+
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.
59+
60+
The client also refreshes auth information when a user switches focus to your tab or reconnects (if they were offline).
61+
62+
```js
63+
const authClient = createClient({
64+
// The base URL where your authentication pages are hosted.
65+
// You can find this under the Frontend Integration section for your project.
66+
authUrl: "https://auth.yourdomain.com",
67+
68+
// If true, periodically refresh the access token in the background.
69+
// This helps ensure you always have a valid token ready to go. Default true.
70+
enableBackgroundTokenRefresh: true,
71+
});
72+
```
73+
2074
## Questions?
2175

2276
Feel free to reach out at support@propelauth.com

0 commit comments

Comments
 (0)