Fumapress
The site generator

Link Validation

Detect broken links during build.

Installation

This plugin is included in fumapress.

Enable the plugin in your Fumapress config:

press.config.tsx
import { defineConfig } from "fumapress";
import { linkValidationPlugin } from "fumapress/plugins/link-validation";

export default defineConfig({
  // ...
})
  .plugins(linkValidationPlugin());

During static generation, the plugin collects links rendered with <Link /> component. After the build finishes pre-rendering, it validates each unique href:

  • Relative links — fetched against your app. A 404 response fails the build.
  • Absolute URLs — skipped unless you provide an externalLink callback.

If any link is broken, the build throws an error listing the source page and target URL:

In "/docs/getting-started": link "/docs/missing-page" not-found

Options

ignored

Skip validation for specific links:

press.config.tsx
import { linkValidationPlugin } from "fumapress/plugins/link-validation";

export default defineConfig({
  // ...
}).plugins(
  linkValidationPlugin({
    ignored(href) {
      return href.startsWith("https://example.com");
    },
  }),
);

Validate external (absolute) URLs. Return "not-found" to fail the build, or null when the link is valid:

press.config.tsx
import { linkValidationPlugin } from "fumapress/plugins/link-validation";

export default defineConfig({
  // ...
}).plugins(
  linkValidationPlugin({
    async externalLink(href) {
      const res = await fetch(href, { method: "HEAD" });
      return res.ok ? null : "not-found";
    },
  }),
);

Only links rendered through Link from fumapress/client during pre-rendering are tracked, it doesn't work for normal <a /> tags.

Last updated on

On this page