snapcrawl-express-ssr
v1.0.3
Published
Express middleware that serves pre-rendered HTML from SnapCrawl's SSR API to improve SEO for JavaScript apps.
Maintainers
Readme
SnapCrawl Express Middleware
This middleware intercepts requests from known bots (Googlebot, ChatGPT, Bing, etc.) and serves pre-rendered HTML content from SnapCrawl's SSR API. This ensures optimal SEO for JavaScript-heavy applications like React, Vue, Angular SPAs.
Features
- Detects popular bots via
User-Agent - Detects desktop vs mobile crawlers
- Skips rendering for static assets (like
.js,.png,.css, etc.) - Fetches HTML from SnapCrawl API and serves to the bot
Free Credits, Billing & Your API Secret
🔑 Get your API secret
- Create an account (or sign in): snapcrawl.io
- Go to your Dashboard → Secret keys
- Copy your Secret Key
Installation
npm install snapcrawl-expressUsage
import express from "express";
import snapcrawlMiddleware from "snapcrawl-express";
const app = express();
app.use(
snapcrawlMiddleware({
secret: "your-snapcrawl-api-secret",
})
);
app.listen(3000);How It Works
- Middleware checks the
User-Agentheader to identify if it's a bot. - Skips requests for static assets like
.js,.jpg, etc. - If it's a bot requesting an HTML route, it sends a request to SnapCrawl's SSR API.
- The API returns the pre-rendered HTML and serves it directly to the bot.
List of Known Bots
A sample of detected bots includes:
- Googlebot
- Bingbot
- GPTBot
- FacebookExternalHit
- TwitterBot
- ChatGPT-User
- DiscordBot
- and many more...
Options
| Option | Type | Required | Description |
| -------- | ------ | -------- | ------------------------------ |
| secret | String | ✅ | Your SnapCrawl API secret key. |
