next-validate-link is a utility designed to check and ensure the validity of links within Markdown files. It supports various modern web frameworks, including Next.js, Astro, Nuxt, Waku, and React Router, by offering specialized presets for their routing conventions. The package is currently stable at version 1.6.4, with a consistent release cadence of minor and patch updates, indicating active development and continuous improvement. Its core functionality involves scanning specified directories for Markdown files and then validating both internal and external URLs, as well as relative file paths, providing comprehensive link integrity checks essential for documentation sites and content-heavy applications. A key differentiator is its extensibility with custom remark plugins and customizable Markdown validators, ensuring flexibility for diverse project needs.
npm install next-validate-linkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `next-validate-link` to scan your project's Markdown files, resolve internal and external links using framework presets, and report any validation errors. It includes common configuration options for different link types and integrates the `printErrors` helper for clear output.
Update handlers for `validateFiles` to iterate over `ValidateResult[]` and access errors via `result.errors` property, rather than directly processing `ValidateError[]`.
Ensure `baseUrl`, `checkRelativePaths`, `checkRelativeUrls`, and potentially `pathToUrl` options are correctly configured to match your deployment environment and routing conventions. For Next.js, using the `next` preset in `scanURLs` is often sufficient.
For complex routing scenarios, you may need to manually provide an array of all valid `pages` to the `scanURLs` function or implement a custom `pathToUrl` resolver within `validateFiles` options.
Verify the glob pattern and the starting directory. Ensure that the path segments (e.g., `docs`, `content`) correctly reflect your project's structure and that the file extensions (e.g., `md`, `mdx`) are correct. Use `path.join(process.cwd(), 'your-glob')` for robust path resolution.
Ensure you are using `import { validateFiles } from 'next-validate-link';` and that your project is configured to handle ESM, especially if running directly with Node.js or older environments. If using `require`, you might need dynamic `import()` or adjust your build system.Check the reported link in the Markdown file (`file.md` at line 10, column 15). Verify if the target page or resource actually exists at the specified path/URL, or if the link is malformed. If it's a relative link, ensure your `baseUrl` and `pathToUrl` configurations are correct. If it's an external link, confirm network connectivity and the external resource's availability.
No dependency data recorded yet.