-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FAQ about using from CDN (#1136)
- Loading branch information
1 parent
37d8af5
commit d4360b1
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
``` |