# Customize how LLMs see your React pages

Redocly publishes a plain Markdown copy of every page for AI clients.
The `.md` version of a page, the `llms.txt` file, AI search, and the MCP server all read this copy instead of the rendered HTML.

A [React page](/docs/platform/customization/create-react-page) has no Markdown source.
Redocly renders the page on the server and converts the HTML to Markdown.
The copy has the content that the HTML contains when the page loads.
Content that the page creates only after a click isn't in the copy.
For example, the copy leaves out list items that a button adds and the text in a dialog.

To add that content to the copy, use the `useIsMarkdownRender` hook.

## Check what the copy contains

To open the copy, add `.md` to the page URL, for example `/menu.md`.
The preview server and the built project both return the copy.

Redocly converts the HTML with the following rules:

- Redocly converts the content area of the theme, the element with the `content` ID.
  If the page has no content area, Redocly converts the first `<main>` element.
  If the page has neither, Redocly converts the whole page except its `<nav>`, `<header>`, `<footer>`, and `<aside>` elements.
- Each language of the page gets its own copy, with the text of that language.

The copy keeps the following content:

- Content that a stylesheet hides, such as the body of a closed accordion.
- An image with alternative text, as a Markdown image.
- A card that is a link, with its link on its heading or on its first line of text.
- An `<iframe>` with a web address, such as an embedded YouTube video, as a link to its address.
  Inside a link, the `<iframe>` gives the link its title.
- A button inside a link, as the text of the link.

The copy leaves out the following content:

- Content with the `hidden` attribute, with `aria-hidden="true"`, or with an inline `display: none` or `visibility: hidden` style.
- Buttons, form fields, SVG images, and `<script>`, `<style>`, `<noscript>`, and `<template>` elements.
- Native `<dialog>`, `<video>`, `<audio>`, `<canvas>`, `<embed>`, and `<object>` elements, and all content inside them.
- An image without alternative text.
- An `<iframe>` with a width or height of 0 or 1 pixel.

If the copy already has all the content of the page, the page needs no change.

## Add content to the copy

`useIsMarkdownRender` returns `true` only when Redocly renders the page for its Markdown copy.
In the browser and in the server render of the page for readers, it returns `false`.
The page that readers see doesn't change.

**Security considerations**

Redocly publishes the content that the page renders for its copy to AI clients and to anyone who requests the Markdown copy.
Never render secrets, API keys, tokens, or other sensitive information when the hook returns `true`.

Don't use the hook for content that readers must see in the browser.
The hook returns `false` there, so readers never see that content.

To add content to the copy:

Import `useIsMarkdownRender` from `@redocly/theme/core/hooks`.

Call the hook at the top of the page component.

When the hook returns `true`, render the content that the page displays only after a click.

The following example page displays the first six items of the Redocly Cafe menu and a **Show all** button.
Each card opens a dialog with the item description.
The page uses the hook to put all menu items and their descriptions in the copy.

The following excerpt of the data file lists two menu items:

```json
[
  {
    "id": "flat-white",
    "name": "Flat white",
    "category": "Coffee",
    "description": "A double shot of espresso with a thin layer of steamed milk."
  },
  {
    "id": "blueberry-muffin",
    "name": "Blueberry muffin",
    "category": "Bakery",
    "description": "A muffin baked every morning with fresh blueberries."
  }
]
```

The page component reads the data file:

```tsx
import * as React from 'react';
import { useIsMarkdownRender } from '@redocly/theme/core/hooks';

import menu from './data/menu.json';

type MenuItem = (typeof menu)[number];

const INITIAL_COUNT = 6;

export default function MenuPage() {
  const isMarkdownRender = useIsMarkdownRender();
  const [showAll, setShowAll] = React.useState(false);
  const [selected, setSelected] = React.useState<MenuItem | null>(null);

  const visible = showAll ? menu : menu.slice(0, INITIAL_COUNT);

  return (
    <main>
      <h1>Menu</h1>
      <ul className="menu-grid">
        {visible.map((item) => (
          <li key={item.id}>
            <button type="button" onClick={() => setSelected(item)}>
              {item.name}
            </button>
          </li>
        ))}
      </ul>
      {!showAll && menu.length > INITIAL_COUNT && (
        <button type="button" onClick={() => setShowAll(true)}>
          Show all
        </button>
      )}
      {selected && (
        <div role="dialog" aria-label={selected.name}>
          <h2>{selected.name}</h2>
          <p>{selected.description}</p>
          <button type="button" onClick={() => setSelected(null)}>
            Close
          </button>
        </div>
      )}
      {isMarkdownRender && (
        <ul>
          {menu.map((item) => (
            <li key={item.id}>
              <strong>{item.name}</strong> ({item.category}): {item.description}
            </li>
          ))}
        </ul>
      )}
    </main>
  );
}
```

The cards are buttons, so their names aren't in the copy.
When the hook returns `true`, the page adds a list of all menu items, with the category and description of each.
For the two menu items in the excerpt, the copy contains:

```md
# Menu

- **Flat white** (Coffee): A double shot of espresso with a thin layer of steamed milk.
- **Blueberry muffin** (Bakery): A muffin baked every morning with fresh blueberries.
```

## Resources

- **[Create React pages](/docs/platform/customization/create-react-page)** - The page files whose Markdown copy you customize
- **[Customize how LLMs see your tags](/docs/platform/customization/render-tags-for-llms)** - Markdown output of custom Markdoc tags on a Markdown page
- **[Make docs AI ready](/docs/platform/ai-ready)** - Features that read the Markdown copy: `llms.txt`, AI search, and the MCP server
- **[Visibility tag](/docs/platform/content/markdoc-tags/visibility)** - Content for readers only or AI clients only on a Markdown page, without code
