PHPackages                             spatie/commonmark-wire-navigate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. spatie/commonmark-wire-navigate

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

spatie/commonmark-wire-navigate
===============================

Add a wire:navigate attribute to links rendered in Markdown

1.1.0(1y ago)1010.7k↓47.4%2[1 PRs](https://github.com/spatie/commonmark-wire-navigate/pulls)MITPHPPHP ^8.1CI failing

Since Mar 15Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/spatie/commonmark-wire-navigate)[ Packagist](https://packagist.org/packages/spatie/commonmark-wire-navigate)[ Docs](https://github.com/spatie/commonmark-wire-navigate)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-commonmark-wire-navigate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (6)Used By (0)

Add a wire:navigate attribute to links rendered in Markdown
===========================================================

[](#add-a-wirenavigate-attribute-to-links-rendered-in-markdown)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b5e074e3e4f745bc82464a9f2e07862cb70ab2c339efd8d04a919b2add43d0f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f636f6d6d6f6e6d61726b2d776972652d6e617669676174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/commonmark-wire-navigate)[![Tests](https://camo.githubusercontent.com/e50e88d98cf22e5301bc0c115490138049bd0c554bd33bcc100bcf6ea8161b33/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f636f6d6d6f6e6d61726b2d776972652d6e617669676174652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/commonmark-wire-navigate/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/63a2e7720ce6b1cc3cd7332ee916c849f5b440ffad51476329c0fb65d3de75e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f636f6d6d6f6e6d61726b2d776972652d6e617669676174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/commonmark-wire-navigate)

An extension for [league/commonmark](https://github.com/thephpleague/commonmark) to add a `wire:navigate` attribute to links rendered in Markdown and enable [SPA mode](https://livewire.laravel.com/docs/navigate) in Livewire.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/e0534f68da11ecba06a935d986de05296dda137062590b6724a639314fab6a5d/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f636f6d6d6f6e6d61726b2d776972652d6e617669676174652e6a70673f743d31)](https://spatie.be/github-ad-click/commonmark-wire-navigate)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/commonmark-wire-navigate
```

Usage
-----

[](#usage)

Register `CommonMarkWireNavigate` as a CommonMark extension.

```
use League\CommonMark\Environment\Environment;
use League\CommonMark\CommonMarkConverter;
use Spatie\CommonMarkWireNavigate\WireNavigateExtension;

$converter = new CommonMarkConverter($environment);
$converter->getEnvironment()->addExtension(new WireNavigateExtension());

echo $converter->convert('[About](/about)');
// About
```

For more information on CommonMark extensions and environments, refer to the [CommonMark documentation](https://commonmark.thephpleague.com/2.4/basic-usage/).

### Laravel-markdown

[](#laravel-markdown)

When using the [Laravel-markdown](https://github.com/spatie/laravel-markdown/) package, you may register the extension in `config/markdown.php`:

```
/*
 * These extensions should be added to the markdown environment. A valid
 * extension implements League\CommonMark\Extension\ExtensionInterface
 *
 * More info: https://commonmark.thephpleague.com/2.4/extensions/overview/
 */
'extensions' => [
    Spatie\CommonMarkWireNavigate\WireNavigateExtension::class,
],
```

### Choosing which links to enhance

[](#choosing-which-links-to-enhance)

By default, the extension will add `wire:navigate` to all internal links except fragments of the current page. To know which link is internal, you must specify your application's base URL.

```
$converter = new CommonMarkConverter($environment);
$converter->getEnvironment()->addExtension(new WireNavigateExtension(
    baseUrl: 'https://example.app',
));

echo $converter->convert('[About](/about)');
// About

echo $converter->convert('[About](https://example.app/about)');
// About

echo $converter->convert('[Twitter](https://twitter.com/spatie_be)');
// Twitter
```

Additionally, you can configure whether the attribute will be added using an array of patterns or a callback.

Using an array to specify a root path in your application:

```
$converter = new CommonMarkConverter($environment);
$converter->getEnvironment()->addExtension(new WireNavigateExtension(
    baseUrl: 'https://example.app',
    enabled: ['docs', 'guide'],
));

echo $converter->convert('[Installation](/docs/installation)');
// Installation

echo $converter->convert('[Guide](/guide)');
// Guide

echo $converter->convert('[About](/about)');
// About
```

Using a callback:

```
$converter = new CommonMarkConverter($environment);
$converter->getEnvironment()->addExtension(new WireNavigateExtension(
    baseUrl: 'https://example.app',
    enabled: fn (string $url) => preg_match('/\/docs\//', $url),
    hover: true,
));
```

Enable on fragments of the current page:

```
$converter = new CommonMarkConverter($environment);
$converter->getEnvironment()->addExtension(new WireNavigateExtension(
    fragment: true,
));
```

### Prefetching pages on hover

[](#prefetching-pages-on-hover)

If you want to have Livewire prefetch pages when a link is hovered, enable the `hover` option.

```
$converter = new CommonMarkConverter($environment);
$converter->getEnvironment()->addExtension(new WireNavigateExtension(
    baseUrl: 'https://example.app',
    hover: true,
));
```

Now the extension will add `wire:navigate.hover` to links instead.

```
echo $converter->convert('[About](/about)');
// About
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance66

Regular maintenance activity

Popularity34

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~165 days

Total

2

Last Release

629d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (23 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (3 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (3 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![GeertHauwaerts](https://avatars.githubusercontent.com/u/7902071?v=4)](https://github.com/GeertHauwaerts "GeertHauwaerts (1 commits)")[![francoism90](https://avatars.githubusercontent.com/u/5028905?v=4)](https://github.com/francoism90 "francoism90 (1 commits)")

---

Tags

spatiemarkdownlivewirecommonmark-wire-navigatecommmonmark

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-commonmark-wire-navigate/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-commonmark-wire-navigate/health.svg)](https://phpackages.com/packages/spatie-commonmark-wire-navigate)
```

###  Alternatives

[spatie/laravel-markdown

A highly configurable markdown renderer and Blade component for Laravel

4053.4M35](/packages/spatie-laravel-markdown)[daux/daux.io

Documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly

825191.0k1](/packages/daux-dauxio)[spatie/sheets

Store &amp; retrieve your static content in plain text files

30187.7k4](/packages/spatie-sheets)[spatie/laravel-markdown-response

Serve markdown versions of your HTML pages to AI agents and bots

6512.6k](/packages/spatie-laravel-markdown-response)[torchlight/torchlight-commonmark

A Commonmark extension for Torchlight, the syntax highlighting API.

29256.6k6](/packages/torchlight-torchlight-commonmark)[maglnet/magl-markdown

Provides a ZF2 View Helper to render markdown syntax. It uses third-party libraries for the rendering and you can switch between different renderers.

22178.2k4](/packages/maglnet-magl-markdown)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
