Adaptive content
Show each reader the pages and blocks that apply to them — their plan, role or region.
Adaptive content changes pages based on details your product passes about the reader, called
claims: plan, role, region, a feature flag — anything that fits in a short value.
Adaptive content is part of the Business plan. Turn on Read visitor claims in the site's Customize → AI & features.
Write conditions#
A condition is a small expression over claims:
visitor.claims.plan == "pro" && !visitor.claims.trial
seats >= 10
visitor.claims.roles.includes("admin")You can use ==, !=, <, <=, >, >=, &&, ||, !, parentheses, strings, numbers, true,
false, null and .includes() on lists and text. visitor.claims.plan and plan mean the same
claim. A missing claim is null, and an expression that doesn't parse never holds.
Conditions go in two places:
Conditional content — type
/conditional, write the expression, and put blocks inside. Only readers who meet it see them.A page's condition — the page appears in navigation, previous/next links, search and llms.txt only for readers who meet it. Its sub-pages follow it.
{% if visitor.claims.plan == "enterprise" %}
{% hint style="success" %}
Your plan includes SAML single sign-on.
{% endhint %}
{% endif %}Pass claims#
Have your app set a docsheaf-visitor cookie on the docs domain holding a JSON object of claims:
document.cookie = 'docsheaf-visitor=' + encodeURIComponent(JSON.stringify({ plan: 'pro', region: 'eu' }))
+ '; domain=.example.com; path=/; secure; samesite=lax';Add ?visitor.<claim>=value to a link into the docs:
https://docs.example.com/billing?visitor.plan=proDocsheaf remembers URL claims on that site for 30 days.
Have your backend sign the claims as a short-lived JWT with the site's key and link with
?visitor_token=<jwt>, or set a docsheaf-visitor-token cookie. See
signed visitor tokens.
Personalize or protect#
Unsigned claims — cookies and URL parameters — personalize, they don't protect. Anyone can set them, a conditional page still opens by its URL, and search and the AI assistant read every block.
To protect content, create a signing key and turn on Trust only signed claims. Docsheaf then reads claims only from tokens signed with that key, and conditions become access rules:
A page whose condition fails answers "not found" — on the site, as
.md, and through the MCP server.Search returns only pages the reader may see, and quotes only the text they can see.
The AI assistant leaves out what the reader can't see.
Test as a reader#
Open a page with ?visitor.plan=pro (or any claim) to see it as such a reader. llms.txt, llms-full.txt,
.md files, the sitemap and the MCP server always show what a reader without claims sees.
Was this helpful?
Last updated
View as Markdown