Starlette middleware that intercepts crawler requests and serves prerendered HTML from a Prerender service for SEO optimization.
Prerender Python Starlette is a middleware for Starlette-based web applications that improves SEO by serving prerendered HTML to search engine crawlers. It intercepts crawler requests and forwards them to an external Prerender service, which returns static HTML instead of JavaScript-heavy pages. This solves indexing issues for sites built with frameworks like Angular, React, or Vue.
Developers building Starlette or FastAPI applications with JavaScript frontends who need to ensure their sites are properly indexed by search engines. It's particularly useful for teams relying on dynamic rendering for SEO.
It provides a lightweight, configurable middleware that seamlessly integrates Prerender services into Python ASGI apps, offering caching hooks and compatibility with major crawlers without requiring complex setup.
Starlette middleware for Prerender
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a predefined list of user-agent strings to reliably intercept requests from major search engines like Google and Bing, ensuring only crawler traffic is redirected to the Prerender service.
Supports environment variables for service URLs and authentication, plus customizable whitelist and blacklist patterns, allowing fine-grained control over which paths are prerendered.
Provides async before_render and after_render callbacks, enabling developers to implement custom caching logic to reduce load on the Prerender service and improve response times.
Designed for Starlette but works seamlessly with FastAPI and other ASGI frameworks, making it a versatile choice for modern Python web applications without lock-in.
Relies entirely on a third-party Prerender service (e.g., Prerender.io), which introduces an external point of failure, potential latency, and ongoing costs that may not suit all budgets.
While hooks are provided, the middleware lacks default caching mechanisms; teams must implement their own from scratch, which can be error-prone and time-consuming.
Only compatible with ASGI frameworks like Starlette and FastAPI, excluding popular WSGI frameworks such as Django or Flask unless they are migrated to ASGI, adding complexity for some teams.