Skip to content

Starlight Page Context Action

starlight-page-context-action is a Starlight plugin that adds page action buttons to the right sidebar, above/below the table of contents.

  • Copy page — Copies the raw markdown content of the current page to your clipboard.
  • Open in Chat — Opens the page in ChatGPT, Claude, or T3 Chat with a configurable prompt.
  • Scroll to top — Smoothly scrolls back to the top of the page.
  • Mobile support — Actions are also available on mobile via a compact dropdown in the mobile table of contents bar.
  • Zero-config — Works out of the box with sensible defaults.
  • Per-page opt-out — Disable actions on specific pages via frontmatter.

Install the plugin in your Starlight project:

Terminal window
npm install starlight-page-context-action

Add it to your astro.config.mjs:

import starlightPageContextAction from "starlight-page-context-action";
export default defineConfig({
integrations: [
starlight({
title: "My Docs",
plugins: [starlightPageContextAction()],
}),
],
});

Check the sidebar for Page Actions — you should see the “Copy page”, “Open in Chat”, and “Scroll to top” buttons on the right side of this page.

The plugin overrides Starlight’s PageSidebar component to inject a PageContextActions component before the table of contents. It also overrides the MobileTableOfContents component to add a compact “Page Actions” dropdown alongside the mobile table of contents toggle — so actions are accessible on all screen sizes. Raw markdown files are copied to the build output so the “Copy page” button can fetch and copy the source content.