On this page
The short answerMap the source before testingWhy Nextra examples breakInventory fences and run JavaScriptAdd a build and source check to CIHow DocsAlive reads NextraTriage findings and coverage gapsPlan coverage around reader pathsWhere DocsAlive fitsThe sources we checkedFAQThe short answer
Test Nextra examples from the authored source and from the reader’s intended path: inventory fences in content/, app/ and any older pages/ tree, run complete examples in suitable environments, and explicitly cover tab alternatives and generated content. A successful Next.js build does not prove the commands and code shown in the site still work.
Nextra 4 uses the Next.js App Router. Content can live in a content/ directory served through a catch-all route, or in page.mdx files under app/. Older projects may still have documentation under pages/. A migration can leave examples, imports and test paths referring to the old layout.
DocsAlive handles Nextra as plain Markdown and MDX in engine 0.6.3. It reads ordinary fence metadata without changing the language, but it has a verified limitation with Nextra’s Tabs.Tab structure: later same-language blocks can be skipped as alternatives. Treat those skips as unchecked and cover the affected blocks with your own CI script.
For general practice, see testing documentation code and testing static-site documentation.
Map the source before testing
A Nextra 4 site can use a content/ directory with a catch-all route such as app/[[...mdxPath]]/page.jsx. It can also place page.mdx files directly in the App Router tree. Earlier Nextra versions commonly used pages/. A repository may temporarily contain more than one of these layouts during migration, so inspect the actual source rather than assuming one directory is complete.
Code blocks use syntax highlighting at build time. Fence metadata can identify a filename, enable copying or line numbers, highlight lines, or highlight a substring. That metadata helps readers understand the example, but it is not part of the program. A source scanner should take the first word of the fence info string as the language and leave the rest as presentation metadata.
Nextra’s Tabs component uses an items list and a Tabs.Tab for each choice. storageKey can persist a reader’s selection, while defaultIndex chooses an initial tab. Those interface features make alternatives easier to navigate; they do not establish that every alternative installs or runs correctly.
The npm2yarn feature generates package-manager tabs from one source fence containing an npm command. The pnpm, yarn and bun variants appear in built output rather than as independent commands in that source fence. Review the generated variants if you support them, especially when a command contains options or syntax whose translation matters.
Why Nextra examples break
A package name or CLI flag can change while an old command remains in a page. Package-manager alternatives can drift apart when authors maintain them manually. A code example can use an API from a different framework version than the version installed earlier in the tutorial.
MDX adds another dependency: imports and components must still resolve in the project layout. An App Router migration can move a page while leaving an import path or a CI scan pointed at pages/. A page can build in one repository state and fail after a component or dependency is renamed.
Some visible examples are not stored as ordinary fenced blocks. A component can render code from props, fetch remote content or receive content generated during a build. Scanning checked-in Markdown and MDX will not find an example that only exists in that later output. Identify its source and test or inventory it at the stage where it exists.
A highlighted snippet may also be an intentional fragment. Running it in isolation can produce a missing-variable failure even when the surrounding tutorial supplies the value. Conversely, a test that silently supplies undocumented setup can hide a real gap. Keep the reader’s starting state visible.
Classify the blocks
| Source form | Suitable treatment | Coverage question |
|---|---|---|
| Complete JavaScript block | Run in the documented runtime and environment | Does it require prior page state or local files? |
| Shell command | Run only under a deliberate safety and environment policy | Does it install or modify anything? |
| Manual package-manager tabs | Test supported alternatives separately | Are the commands still equivalent? |
npm2yarn source fence |
Test the npm source and inspect generated alternatives | Are the built variants appropriate for the supported tools? |
| Fragment or highlighted edit | Review in context and test a complete fixture | Can a reader reach the final working state? |
| MDX import or component | Build and test the page or component | Did a migration change the import path? |
| Remote or generated example | Test at its source or after generation | Is the visible example present in the scanned repository? |
| Output sample | Assert stable claims separately | Which values may vary? |
A classification is useful when it drives a decision. “Skipped” should mean that a maintainer knows why a block was not run and where any needed coverage lives.
Inventory fences and run JavaScript
Save the following as check_nextra.py at the repository root and run python3 check_nextra.py. It requires Python 3.12 or later and Node 20 or later. The script scans existing content/, app/ and pages/ trees for .md and .mdx files.
It reports counts by language, identifies npm2yarn metadata, and runs js blocks in separate temporary files. It skips a block when its first line is // fragment or # fragment. Shell blocks are inventoried but not executed by this script.
#!/usr/bin/env python3
from collections import Counter
from pathlib import Path
import re
import subprocess
import sys
import tempfile
ROOTS = [Path("content"), Path("app"), Path("pages")]
SUFFIXES = {".md", ".mdx"}
OPEN = re.compile(r"^ {0,3}(`{3,}|~{3,})(.*)$")
def blocks(path):
lines = path.read_text(encoding="utf-8").splitlines()
index = 0
while index < len(lines):
match = OPEN.match(lines[index])
if not match:
index += 1
continue
marker = match.group(1)
info = match.group(2).strip()
words = info.split()
language = words[0].lower() if words else "(unlabeled)"
start = index + 1
index += 1
body = []
close = re.compile(
r"^ {0,3}" + re.escape(marker[0])
+ r"{" + str(len(marker)) + r",}\s*$"
)
while index < len(lines) and not close.match(lines[index]):
body.append(lines[index])
index += 1
yield start, language, words[1:], "\n".join(body), index < len(lines)
index += 1
def main():
roots = [root for root in ROOTS if root.is_dir()]
if not roots:
print("No content, app or pages directory found", file=sys.stderr)
return 1
counts = Counter()
failures = 0
executed = 0
fragments = 0
generated_tabs = 0
for root in roots:
paths = sorted(p for p in root.rglob("*") if p.suffix in SUFFIXES)
for path in paths:
for line, language, meta, body, closed in blocks(path):
counts[language] += 1
location = f"{path}:{line}"
if not closed:
print(f"FAIL {location}: unclosed fence")
failures += 1
if "npm2yarn" in meta:
print(f"INFO {location}: npm2yarn; only npm is in source")
generated_tabs += 1
first = body.splitlines()[0].strip() if body.splitlines() else ""
if first in {"// fragment", "# fragment"}:
print(f"SKIP {location}: fragment")
fragments += 1
continue
if language != "js":
continue
with tempfile.TemporaryDirectory() as directory:
script = Path(directory) / "block.js"
script.write_text(body + "\n", encoding="utf-8")
try:
result = subprocess.run(
["node", str(script)],
capture_output=True,
text=True,
timeout=30,
check=False,
)
except (OSError, subprocess.TimeoutExpired) as error:
print(f"FAIL {location}: {error}")
failures += 1
continue
executed += 1
if result.returncode:
print(f"FAIL {location}: node exited {result.returncode}")
print(result.stderr, end="")
failures += 1
else:
print(f"PASS {location}")
print("\nBlocks by language:")
for language, count in sorted(counts.items()):
print(f" {language}: {count}")
print(
f"Executed: {executed}; fragments: {fragments}; "
f"npm2yarn fences: {generated_tabs}; failures: {failures}"
)
return 1 if failures else 0
if __name__ == "__main__":
sys.exit(main())
The script uses the first word of the info string as the language. Metadata such as filename=, copy, showLineNumbers and brace-based highlights does not become part of the language. The script reports an npm2yarn fence because only its npm command is present in source; it does not test the generated package-manager choices.
This is a small source scanner, not a complete MDX parser. It handles ordinary backtick and tilde fences, but unusual nesting or code assembled by components needs separate review. It also runs only the js label. A javascript, TypeScript or shell block is counted but not executed.
Each JavaScript block runs in its own temporary file. That means it cannot rely on variables from an earlier block, and relative imports resolve from the temporary directory. Use a separate test for a tutorial sequence, repository-relative files or installed packages. Do not use the fragment marker to conceal a complete example that should run.
Cover shell and package-manager paths deliberately
The script does not execute shell blocks because a documentation command may install software, contact a service or modify files. Create dedicated tests for commands you intend to run, with a clean working directory and clear prerequisites. Test each supported package-manager path separately when its setup differs.
For npm2yarn, the checked-in npm command is the source of the generated tabs. A passing npm check is useful, but it is not proof that every generated command behaves as intended with its package manager. Inspect the rendered choices and run representative generated commands in their own environments. Fumadocs has a similar transform for npm fences; see testing Fumadocs documentation examples.
When a page shows a diff or an incomplete change, test the completed file a reader should have after following the instructions. Keep the starting fixture and the intended result close to the tutorial so a later edit prompts a review of both.
Add a build and source check to CI
The following workflow is illustrative configuration. It assumes a lockfile, an npm build script and the checker above at the repository root. Adapt the triggers and commands to the repository.
name: Documentation checks
on:
push:
pull_request:
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm ci
- run: npm run build
- run: python3 check_nextra.py
The build can catch broken MDX imports and rendering integration problems that a fence scanner does not see. The source script can identify and run a narrow class of examples that a build may only render. Neither check establishes that a remote API, generated example or every tab works.
Record the runtime and package versions used by CI. If documentation describes a released package, test the artifact a reader will install as well as the checkout where appropriate. A passing check against an unpublished local change does not prove the published installation path works.
How DocsAlive reads Nextra
Engine 0.6.3 does not detect Nextra configuration as a dedicated framework. It handles the repository as plain Markdown and MDX. Without a top-level docs/ directory, Markdown and MDX files under the repository root are scanned subject to excluded directories; .next is excluded. If a top-level docs/ directory exists, the default selection is that directory plus the README. Review the selected pages and use the CLI’s --docs-dir option when the intended content is elsewhere.
Fence metadata such as a filename, copying option, line-number option or line highlight leaves the first-word language intact. The engine plans supported languages according to their own rules. An unmapped label is a known limitation: it can be reported as passing without execution or parsing. Treat that as unchecked.
The engine sees an npm2yarn source fence as one block containing the npm command. It does not see the pnpm, yarn and bun variants generated only in built HTML as separate source blocks. Remote content and examples generated at build time are likewise absent from a source scan when they are not present as scanned files.
The verified Tabs.Tab limitation
Nextra’s Tabs.Tab children are not recognized as one ordinary tab group in engine 0.6.3. Each opening Tabs.Tab line starts a new group, and its closing line does not close that group in the parser. This has two practical effects.
First, each tab’s block is planned separately instead of selecting one variant for the whole Nextra component. For a package-manager group, the npm command can run while pnpm and yarn commands are skipped as host-tool commands.
Second, a block after the tabs can be incorrectly grouped with a tab block. If that later block has the same language as the tab, such as a later sh block after an npm sh tab, it can be skipped with the reason “alternative variant.” That later block did not run. Read these skips on Nextra pages as unchecked and cover the affected blocks with your own CI script.
| Block or source form | Engine behavior in 0.6.3 |
|---|---|
| Markdown or MDX fence in a scanned page | Extracted and planned according to language and contents |
| Fence with Nextra presentation metadata | First word remains the language; metadata does not become code |
Nextra Tabs.Tab children |
Each tab is planned separately because the children are not recognized as one group |
| Later same-language block after tabs | Can be incorrectly skipped as an alternative variant; treat it as unchecked |
| pnpm or yarn command | Can be skipped as a host-tool command |
npm2yarn source fence |
One npm source block is seen; generated alternatives are not separate source blocks |
| Remote or build-generated content absent from source | Not scanned |
| Unmapped language label | Reported as pass without being run or parsed |
jsx or tsx |
Not judged |
| Recognized output block | Skipped; contents are not validated |
A block introduced as output or response is not compared with program output. Printed output is compared only for pycon or python-repl sessions. Add independent assertions for JavaScript values, HTTP responses and other output claims.
Network and credential rules also affect coverage. Blocks containing HTTP URLs, package installation commands or npx are marked as needing network; with --no-network, applicable shell and HTTP blocks are skipped. Common credential placeholders cause a skip categorized as needing credentials. Review those reasons before interpreting a report as coverage of the full page.
Triage findings and coverage gaps
| Finding | Investigate | Action |
|---|---|---|
| MDX build fails after moving a page | Component and import paths, App Router layout | Repair the import or move the shared component deliberately |
| JavaScript block fails in isolation | Earlier state, files and runtime version | Test the complete reader path and clarify setup |
| Later block is skipped as an alternative | Whether it follows Tabs.Tab and shares a language |
Treat it as unchecked and add an independent CI check |
| pnpm or yarn tab is skipped | Supported package managers and available tools | Run the alternative in its own suitable environment |
npm2yarn source passes |
Generated commands and their actual environments | Inspect and test supported generated variants |
| Unmapped label reports pass | Whether a checker exists | Use a suitable independent parser or runtime |
| Remote example is missing from the scan | Where the content is authored or generated | Test at the source or generated-output stage |
| Output sample is skipped | Which values the page promises | Add a separate assertion for stable claims |
Keep the evidence needed to reproduce a finding: source page and line, package version, runtime, setup, command and observed failure. A missing fixture may reflect a test harness that is too isolated, or a prerequisite that the page fails to explain. Decide which before changing the example.
Plan coverage around reader paths
Start with installation, first use and common configuration. For each path, list the files a reader visits, the choices offered in tabs, the dependencies and the expected result. A page-level scanner gives useful locations, while a path-level test can reveal a failure caused by steps interacting across pages.
Treat package-manager tabs as alternatives. Run them in separate environments rather than executing every command in sequence. If a choice is persisted with storageKey, inspect whether the labels and ordering remain understandable across related groups. That is a reader experience check as well as a code check.
For an App Router migration, search both old and new trees until the migration is complete. Check that CI scans the files actually published, that imports resolve from their new locations, and that removed pages do not remain the only tested copies of important examples. A build helps with imports; an inventory helps expose source files that the testing workflow overlooks.
For remote or generated content, identify the system that owns the example. Test its source where possible, and add a check after generation if the build transforms the command or code. A source-only report cannot provide evidence about content it never received.
Use this checklist during review:
[ ] Identify content, app and older pages source trees.
[ ] Build the site with the intended dependency versions.
[ ] Inventory fences and review their language labels.
[ ] Mark intentional fragments and test their complete context.
[ ] Test supported package-manager alternatives separately.
[ ] Inspect and test generated npm2yarn choices where needed.
[ ] Review alternative-variant skips after Nextra tabs.
[ ] Test MDX imports and components after route migrations.
[ ] Locate remote and build-generated examples.
[ ] Assert important output in a dedicated test.
[ ] Record skipped blocks and the coverage that replaces them.
Where DocsAlive fits
DocsAlive extracts examples from scanned pages, plans supported blocks, executes them when requested and classifies results. It preserves page order for supported examples and provides findings that help distinguish likely documentation defects from missing context, credentials and external failures.
Use the CLI to select the intended source and request execution. A scan without --execute is an extraction and planning pass. Review findings together with the Nextra tab limitation above, and keep independent checks for skipped alternatives, generated content and output assertions.
The Starlight guide covers another MDX-based documentation layout. For API commands inside Nextra pages, the curl and HTTP examples guide explains why status and response assertions need special care. The documentation testing checklist can help turn the inventory into an ongoing review process.
The sources we checked
These sources were read on November 11, 2026.
| Source | What it covers |
|---|---|
| Nextra documentation | Nextra concepts and current documentation |
| Nextra content directory | Content directory and App Router layout |
| Nextra tabs | Tab items, persisted selection and defaults |
| Nextra syntax highlighting | Fence metadata and highlighting |
| Nextra npm2yarn | Generated package-manager alternatives |
| Nextra releases | Published release history |
| GitHub checkout action | Repository checkout in Actions |
| GitHub Node setup action | Selecting Node in Actions |
FAQ
Does a Nextra build execute documentation examples?
A build checks the configured site and can reveal rendering or import errors. It does not establish that every displayed command, response or tutorial sequence works.
Where should I look for Nextra source pages?
Inspect content and app for a Nextra 4 project, and include pages when it exists in an older or migrating repository. Confirm which files the published site actually uses.
How does DocsAlive handle Nextra tabs?
In engine 0.6.3, Tabs.Tab children are planned separately, and a later same-language block can be skipped as an alternative. Treat those skips as unchecked and cover the blocks with your own CI script.
Does an npm2yarn source fence contain every generated command?
No. The source contains the npm command; the other package-manager choices are generated at build time. Inspect and test the generated choices that your project supports.
Are remote or generated examples included in a source scan?
Examples absent from the scanned repository files are not scanned. Test their source or add a check at the stage where the generated content exists.
Does a passing unmapped fence label mean its code ran?
No. Engine 0.6.3 can report an unmapped label as passing without execution or parsing. Treat it as unchecked and use an appropriate independent checker.




