Middleware for Express.js applications to dynamically generate a robots.txt file. Version 1.0.1 is the current stable release, with infrequent updates since 2016. It supports multiple user agents, allow/disallow directives, and crawl-delay configuration. Differentiators include simple integration as route middleware and no external dependencies beyond Express.
npm install express-robots-middlewareVerified import paths — ran on the pinned version, not inferred.
Creates an Express app that serves a robots.txt with a disallow list and crawl delay.
Use exactly { UserAgent: string, Disallow: string[], Allow: string, CrawlDelay: string }Upgrade to 1.0.1 to avoid unexpected behavior with Express error middleware.
Always provide all required fields: UserAgent, Disallow array, Allow, CrawlDelay.
Bind the middleware to the '/robots.txt' route using app.get('/robots.txt', robotsMiddleware).Use const expressRobotsMiddleware = require('express-robots-middleware').default;