Skip to content
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

Add FAQ about using from CDN #1136

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
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
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>
```