Authentication
Use the Docs Embed with sites that require authentication by passing visitor tokens or using authenticated access
Approach 1: Pass token directly (Recommended)
<script src="https://docs.company.com/~gitbook/embed/script.js"></script>
<script>
window.GitBook(
"init",
{ siteURL: "https://docs.company.com" },
{ visitor: { token: "your-jwt-token" } }
);
window.GitBook("show");
</script>import { createGitBook } from "@gitbook/embed";
const gitbook = createGitBook({
siteURL: "https://docs.company.com",
});
const iframe = document.createElement("iframe");
iframe.src = gitbook.getFrameURL({
visitor: {
token: "your-jwt-token",
unsignedClaims: { userId: "123", plan: "premium" },
},
});Approach 2: Cookie-based detection
Common pitfalls
Debugging
Next steps
Last updated
Was this helpful?