ChatGPT and Claude use this. The click calls window.open(url, '_blank', 'noopener,noreferrer'), so the reader keeps the docs tab.
AI Deeplinks
Every doc page carries an "Ask an AI" section inside the Copy page dropdown,
with entries for ChatGPT, Claude, and Cursor. The buttons are page chrome
rendered by components/CopyPageMarkdown.tsx, so there is no MDX tag to write —
the examples below show the URLs each entry builds and the config behind them.
Quick Start
Click the chevron beside the Copy page button, then pick Ask ChatGPT.
- Click the chevron on the right half of the Copy page button. 2. Skip past Copy as Markdown and Copy as Plain Text. 3. Under the Ask an AI header, click Ask ChatGPT.
A new tab opens on chatgpt.com with the prompt already typed. The prompt
itself is fixed text plus the page URL read from window.location.href:
Read and explain this documentation page: https://example.com/features/platform/ai-deeplinksOnly the URL travels. Page content never goes into the prompt, and nothing leaves the browser until the reader clicks an entry.
Adding Options
The same menu carries two more AI targets and two copy formats, so one control covers both "read this yourself" and "hand it to a model".
Copy page
The left half of the split button. One click copies the page as Markdown.
Copy as Markdown
Strips frontmatter, imports, and JSX tags, keeping the inner text of paired components.
Copy as Plain Text
Runs the Markdown pass, then drops heading hashes, fences, link targets, and emphasis marks.
Ask ChatGPT
Opens chatgpt.com in a new tab, prompt in the q parameter.
Ask Claude
Opens claude.ai/new in a new tab, prompt in the q parameter.
Open in Cursor
Navigates the current tab to the cursor:// URI scheme, prompt in the text parameter.
The prompt is passed through encodeURIComponent, so the three finished URLs
look like this:
https://chatgpt.com/?q=Read%20and%20explain%20this%20documentation%20page%3A%20https%3A%2F%2Fexample.com%2Fpage
https://claude.ai/new?q=Read%20and%20explain%20this%20documentation%20page%3A%20https%3A%2F%2Fexample.com%2Fpage
cursor://anysphere.cursor-deeplink/prompt?text=Read%20and%20explain%20this%20documentation%20page%3A%20https%3A%2F%2Fexample.com%2FpageA copy swaps the button face to a check icon and the word "Copied!", and the
aria-label names the format that landed on the clipboard — "Copied as
Markdown" or "Copied as plain text". The dropdown closes on any of four events:
a copy, an AI target click, Escape, or a mousedown outside the control.
Advanced
Add your own tool by pushing an entry onto the AI_TARGETS array in
components/CopyPageMarkdown.tsx.
external: truebehaviorexternal: falsebehaviorCursor uses this. The click sets window.location.href, which hands the
custom scheme to the operating system. If Cursor isn't installed, the OS
prompts and the docs page stays put.
A new entry needs five fields, and buildUrl receives the page URL:
{
id: 'perplexity',
label: 'Ask Perplexity',
icon: <Sparkles className="h-3.5 w-3.5" aria-hidden="true" />,
buildUrl: (pageUrl) =>
`https://www.perplexity.ai/search?q=${encodeURIComponent(AI_PROMPT_TEMPLATE(pageUrl))}`,
external: true,
}To reword the prompt for every target at once, edit AI_PROMPT_TEMPLATE in the
same file instead. Entries render in array order under the Ask an AI header, so
the order you write them is the order readers see.
One detail matters if you write your own buildUrl: the page URL is captured
into state by an effect after mount, and the click handler falls back to
window.location.href when that state is still empty. Either way buildUrl
receives a full absolute URL, never a bare path.
Options
contentstringrequiredProp passed by app/[[...slug]]/page.tsx. The raw MDX of the current page,
used as the source for both copy formats.
idstringStable identifier used as the React key for the menu button.
labelstringText shown in the menu, such as Ask Claude.
iconReact.ReactNodeA Lucide icon sized h-3.5 w-3.5 with aria-hidden="true".
buildUrl(pageUrl: string) => stringReceives the current page URL and returns the target URL to open.
externalbooleantrue opens a new tab with noopener,noreferrer; false navigates the
current tab, which is what custom URI schemes need.
AI_PROMPT_TEMPLATE(pageUrl: string) => stringThe one prompt every target sends. Defaults to Read and explain this documentation page: {pageUrl}.
Copy as MarkdownactionRemoves the frontmatter block and import lines, deletes self-closing
components, keeps the inner text of paired components, and collapses runs of
three or more blank lines.
Copy as Plain TextactionEverything the Markdown pass does, plus heading hashes, code fences, link
targets, and *, _, ~, and backtick marks removed. Bullets normalize to
-.