PHPackages                             jeffersongoncalves/laravel-npm-readme - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jeffersongoncalves/laravel-npm-readme

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jeffersongoncalves/laravel-npm-readme
=====================================

A Laravel package that fetches an npm package's README from the registry document, renders the markdown and caches the resulting HTML. The default renderer strips raw HTML; provide your own renderer callable (and sanitize) to keep it. Rendered HTML is untrusted — sanitize it before display.

v1.0.0(1mo ago)143MITPHP ^8.2

Since Jun 22Compare

[ Source](https://github.com/jeffersongoncalves/laravel-npm-readme)[ Packagist](https://packagist.org/packages/jeffersongoncalves/laravel-npm-readme)[ Docs](https://github.com/jeffersongoncalves/laravel-npm-readme)[ GitHub Sponsors](https://github.com/jeffersongoncalves)[ RSS](/packages/jeffersongoncalves-laravel-npm-readme/feed)WikiDiscussions Synced 2w ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

[![Laravel npm Readme](https://raw.githubusercontent.com/jeffersongoncalves/laravel-npm-readme/master/art/jeffersongoncalves-laravel-npm-readme.png)](https://raw.githubusercontent.com/jeffersongoncalves/laravel-npm-readme/master/art/jeffersongoncalves-laravel-npm-readme.png)

Laravel npm Readme
==================

[](#laravel-npm-readme)

[![Latest Version on Packagist](https://camo.githubusercontent.com/38052ba94238929e54878bca6448fab56e1f1b4d2e9663edde783be995b30d5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6e706d2d726561646d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jeffersongoncalves/laravel-npm-readme)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2bee32b6c84d65db9429767cb9281d2719225bcdbfb38ef3640d4f145b3cb382/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6e706d2d726561646d652f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jeffersongoncalves/laravel-npm-readme/actions?query=workflow%3Arun-tests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/1a99237f01c18c18aded042a055f8112adaed8d40662a2f3ce4c90632d7cbc29/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6e706d2d726561646d652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/jeffersongoncalves/laravel-npm-readme/actions?query=workflow%3A%22Fix+PHP+code+styling%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/47fd05320ff67e304bcf88e8372a804422e46c02a6f735dbbd2bc1b3cc1c121c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6e706d2d726561646d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jeffersongoncalves/laravel-npm-readme)

Fetch an npm package's README straight from the registry document, render the markdown and cache the resulting HTML. The npm registry ships the README markdown inline in the package document, so there is no extra request beyond the registry call.

This is the npm sibling of [`jeffersongoncalves/laravel-github-readme`](https://github.com/jeffersongoncalves/laravel-github-readme).

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

[](#installation)

```
composer require jeffersongoncalves/laravel-npm-readme
```

Optionally publish the config:

```
php artisan vendor:publish --tag="npm-readme-config"
```

Usage
-----

[](#usage)

```
use JeffersonGoncalves\NpmReadme\NpmReadme;

$html = NpmReadme::fetchHtml('https://www.npmjs.com/package/laravel-echo');
// or a scoped package:
$html = NpmReadme::fetchHtml('https://www.npmjs.com/package/@tailwindcss/vite');
```

`fetchHtml()` returns the rendered HTML, or `null` when the URL isn't an npm package, the registry has no document, or the package ships no README. Results are cached on the default cache store (`npm_readme:{package}`) for `config('npm-readme.cache_minutes')`.

`NpmReadme::packageFromUrl($url)` is also public if you only need the package identifier.

Security
--------

[](#security)

The rendered HTML is **untrusted** (third-party package READMEs). The default renderer therefore **strips raw HTML** (`html_input` = `strip`), so an embedded `` cannot become stored XSS.

If you need raw HTML kept, provide your own `renderer` callable in `config/npm-readme.php` — the output is then unsafe and you **must** sanitize it before display, e.g. with [`jeffersongoncalves/laravel-html-sanitizer`](https://github.com/jeffersongoncalves/laravel-html-sanitizer):

```
// config/npm-readme.php
'renderer' => [\App\Support\Markdown::class, 'render'],
```

Configuration
-------------

[](#configuration)

KeyDefaultDescription`cache_minutes``60`Minutes the rendered HTML is cached per package.`registry_url``https://registry.npmjs.org`npm registry base URL.`timeout``8`Registry request timeout in seconds.`user_agent``laravel-npm-readme``User-Agent` header for the registry request.`renderer``null`Optional `callable(string $markdown): string`. When null, an internal CommonMark renderer (GFM + heading permalinks, raw HTML stripped) is used.Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

45d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/411493?v=4)[Jefferson Gonçalves](/maintainers/jeffersongoncalves)[@jeffersongoncalves](https://github.com/jeffersongoncalves)

---

Tags

laraveljeffersongoncalveslaravel-npm-readme

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jeffersongoncalves-laravel-npm-readme/health.svg)

```
[![Health](https://phpackages.com/badges/jeffersongoncalves-laravel-npm-readme/health.svg)](https://phpackages.com/packages/jeffersongoncalves-laravel-npm-readme)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.4M352](/packages/psalm-plugin-laravel)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k113.1M964](/packages/laravel-socialite)[nativephp/mobile

NativePHP for Mobile

1.1k102.1k123](/packages/nativephp-mobile)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M180](/packages/spatie-laravel-health)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5222.6k](/packages/simplestats-io-laravel-client)[spatie/laravel-export

Create a static site bundle from a Laravel app

679153.2k6](/packages/spatie-laravel-export)

PHPackages © 2026

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