Skip to content

Commit

Permalink
Add FAQ about using from CDN (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Sep 20, 2023
1 parent 37d8af5 commit d4360b1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .shiprc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"files": {
"src/version.ts": [],
"README.md": ["{MAJOR}.{MINOR}"]
"README.md": ["{MAJOR}.{MINOR}"],
"FAQ.md": ["{MAJOR}.{MINOR}.{PATCH}"]
},
"postbump": "npm run docs"
}
36 changes: 36 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,39 @@ new Auth0Client({
useCookiesForTransaction: true
});
```

## How to use from a CDN

There are two ways to use our SDK when you want to rely on a Content Delivery Network to host the bundle and not install our SDK through the npm registry.

### Using our own CDN bundle

Our own CDN bundle exposes both `createAuth0Client` and `Auth0Client` on a global `auth0` variable, and can be used as shown below.

```html
<script>
const client = auth0.createAuth0Client({ ... });
// or
const client = new auth0.Auth0Client({ ... });
</script>
```

### Using import maps with unpkg
If you want to use a CDN bundle together with import maps, you will need to use our ESM bundle from unpkg:

```html
<script type="importmap">
{
"imports": {
"@auth0/auth0-spa-js": "https://www.unpkg.com/@auth0/[email protected]/dist/auth0-spa-js.production.esm.js"
}
}
</script>
<script type="module">
import { createAuth0Client, Auth0Client } from '@auth0/auth0-spa-js';
const client = createAuth0Client({ ... });
// or
const client = new Auth0Client({ ... });
</script>
```

0 comments on commit d4360b1

Please sign in to comment.