vlados/laravel-blade-crawler-detect
Detect search engine crawlers and bots directly in your Blade templates. Simple directives let you serve crawler-specific markup, hide dynamic content, or tailor SEO output without touching controllers—keeping views clean and detection logic reusable across any Laravel app.
@user / @unlessuser) let you wrap third-party embeds, chat widgets, carousels, video players, and A/B-test scripts so they render for humans but not for bots. This is a cheap way to ship a "lite" variant of a heavy marketing page without a second template or a device-detection service.jaybizzle/crawler-detect plus Blade directives. Building in-house means owning the UA regex list, keeping it current, and owning the ReDoS surface — none of which is differentiating work.Chrome-Lighthouse UA inflates your score without improving real user experience. Treat the Lighthouse angle as a diagnostic convenience, never as the OKR.Adopt when all of these hold:
0.4.x and treat the upgrade as a scheduled task.~0.5.0) and re-test on minor bumps. There is no 1.0 API-stability commitment yet.Look elsewhere when:
One-liner: a small, free, MIT-licensed Blade helper that lets us render a lighter page for crawlers and keep heavy third-party widgets off the bot render path — roughly a day of integration work for a measurable Lighthouse delta.
For executives: low cost, low risk, reversible. It is a two-directive change confined to templates, with no infrastructure or vendor contract. It removes a known category of noise from our CWV numbers and improves how much of our content bots can actually parse. Be clear about the ceiling: it improves how we present the page, not how fast the page is. It will not close a JS-budget gap, and we should not report the Lighthouse improvement as a product win on its own — hiding widgets from the Lighthouse user agent is scorekeeping, not user value.
For engineering: thin wrapper over jaybizzle/crawler-detect with @user / @unlessuser directives. v0.5.0 makes it Octane-safe — the UA is now read from the current request inside the closure rather than captured at boot, and CrawlerDetect is bound rather than singleton'd so its $_SERVER state no longer leaks across long-lived workers. That was a genuine correctness bug, not a nicety, and it is now covered by real tests (browser, Googlebot, Chrome-Lighthouse, missing UA, oversized UA, @unlessuser). UA strings are clamped to 2048 chars before regex evaluation to blunt ReDoS, which matters because the header is attacker-controlled. Dependency surface went down — spatie/invade removed. Watch items: breaking drop of Laravel 9, string alias 'CrawlerDetect' retained only for BC (prefer the typed binding), and orchestra/testbench/Pest bumps that affect our own test matrix if we mirror their setup.
How can I help you explore Laravel packages today?