PHPackages                             swooinc/laravel-prerender - 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. swooinc/laravel-prerender

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

swooinc/laravel-prerender
=========================

Laravel middleware for prerendering javascript-rendered pages on the fly for SEO

v4.0.1(2y ago)07.4kMITPHPPHP ^8.1

Since Sep 30Pushed 1y agoCompare

[ Source](https://github.com/swooinc/laravel-prerender)[ Packagist](https://packagist.org/packages/swooinc/laravel-prerender)[ RSS](/packages/swooinc-laravel-prerender/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (12)Used By (0)

Laravel Prerender
=================

[](#laravel-prerender)

Google, Facebook, Twitter, Yahoo, and Bing are constantly trying to view your website... but they don't execute javascript. That's why Prerender was built. Prerender is perfect for AngularJS SEO, BackboneJS SEO, EmberJS SEO, and any other javascript framework.

This middleware intercepts requests to your Laravel website or application from crawlers, and then makes a call to the (external) Prerender Service to get the static HTML instead of the javascript for that page.

Prerender adheres to google's `_escaped_fragment_` proposal, which we recommend you use. It's easy:

- Just add `` to the `` of all of your pages
- If you use hash urls (#), change them to the hash-bang (#!), but you can also use HTML5's push-state
- That's it! Perfect SEO on javascript pages.

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

[](#installation)

Require this package run: `composer require swooinc/laravel-prerender`

If you want to make use of the prerender.io service, add the following to your `.env` file:

```
PRERENDER_TOKEN=yoursecrettoken

```

If you are using a self-hosted service, add the server address in the `.env` file.

```
PRERENDER_URL=http://example.com

```

You can disable the service by adding the following to your `.env` file:

```
PRERENDER_ENABLE=false

```

This may be useful for your local development environment.

How it works
------------

[](#how-it-works)

1. The middleware checks to make sure we should show a prerendered page
    1. The middleware checks if the request is from a crawler (`_escaped_fragment_` or agent string)
    2. The middleware checks to make sure we aren't requesting a resource (js, css, etc...)
    3. (optional) The middleware checks to make sure the url is in the whitelist
    4. (optional) The middleware checks to make sure the url isn't in the blacklist
2. The middleware makes a `GET` request to the [prerender service](https://github.com/prerender/prerender) (phantomjs server) for the page's prerendered HTML
3. Return that HTML to the crawler

Customization
=============

[](#customization)

To customize the whitelist and the blacklist, you first have to publish the configuration file:

```
$ php artisan vendor:publish

```

### Whitelist

[](#whitelist)

Whitelist paths or patterns. You can use asterix syntax. If a whitelist is supplied, only url's containing a whitelist path will be prerendered. An empty array means that all URIs will pass this filter. Note that this is the full request URI, so including starting slash and query parameter string.

```
// prerender.php:
'whitelist' => [
    '/frontend/*' // only prerender pages starting with '/frontend/'
],
```

### Blacklist

[](#blacklist)

Blacklist paths to exclude. You can use asterix syntax. If a blacklist is supplied, all url's will be prerendered except ones containing a blacklist path. By default, a set of asset extentions are included (this is actually only necessary when you dynamically provide assets via routes). Note that this is the full request URI, so including starting slash and query parameter string.

```
// prerender.php:
'blacklist' => [
    '/api/*' // do not prerender pages starting with '/api/'
],
```

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

[](#contributing)

I love any contributions! Feel free to create issues or pull requests.

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2014 Jeroen Noten

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 78.3% of commits — single point of failure

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 ~316 days

Recently: every ~223 days

Total

11

Last Release

1082d ago

Major Versions

1.0.x-dev → v2.0.02015-09-02

v2.0.2 → v3.0.02020-12-10

v3.x-dev → v4.0.02023-01-10

PHP version history (4 changes)v1.0.0PHP &gt;=5.4.0

v2.0.0PHP &gt;=5.5.9

v3.0.0PHP &gt;=7.4

v4.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/40590fe8b8c82dfac2530c6f0c0c39dd1dded4c3ad136e15ef2cf3bb20304dad?d=identicon)[ChinLeung](/maintainers/ChinLeung)

---

Top Contributors

[![jeroennoten](https://avatars.githubusercontent.com/u/4370753?v=4)](https://github.com/jeroennoten "jeroennoten (36 commits)")[![ElGatoLoco](https://avatars.githubusercontent.com/u/7573121?v=4)](https://github.com/ElGatoLoco "ElGatoLoco (5 commits)")[![Shokushu](https://avatars.githubusercontent.com/u/6484427?v=4)](https://github.com/Shokushu "Shokushu (2 commits)")[![MichielDeMey](https://avatars.githubusercontent.com/u/793406?v=4)](https://github.com/MichielDeMey "MichielDeMey (1 commits)")[![thoop](https://avatars.githubusercontent.com/u/1259374?v=4)](https://github.com/thoop "thoop (1 commits)")[![weotch](https://avatars.githubusercontent.com/u/77567?v=4)](https://github.com/weotch "weotch (1 commits)")

---

Tags

laravelprerender

### Embed Badge

![Health badge](/badges/swooinc-laravel-prerender/health.svg)

```
[![Health](https://phpackages.com/badges/swooinc-laravel-prerender/health.svg)](https://phpackages.com/packages/swooinc-laravel-prerender)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[nutsweb/laravel-prerender

Laravel middleware for prerendering javascript-rendered pages on the fly for SEO

279165.5k1](/packages/nutsweb-laravel-prerender)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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