Registry / web-framework / react-middleware

react-middleware

JSON →
library2.2.4jsnpmunverified

Connect middleware for serving React components from a standard folder structure (v2.2.4). Allows building React-based sites with a convention-over-configuration approach, automatically compiling assets via webpack. Includes automatic CSS handling from adjacent .styl/.css files, support for custom webpack loaders, and integration with Express. Last updated in 2016, with low release cadence. Differentiates by enforcing a specific folder structure and providing server-side compilation, but is outdated compared to modern frameworks like Next.js.

npm install react-middleware
INSTALL
IMPORT
SIG · REACT-MIDDLEWARE
R
react-middleware
web-frameworkjavascriptv2.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import ReactMiddleware from 'react-middleware'
✗ const ReactMiddleware = require('react-middleware')
Package uses default export. In CJS, require() returns the default export; ensure .default is accessed if needed.

Basic server setup using ReactMiddleware with Express, including build step and listening on port 3030.

import ReactMiddleware from 'react-middleware'; import express from 'express'; const app = express(); const site = ReactMiddleware({ base: './example/site' }); site.build() .then(() => { app .use(site) .listen(3030, () => { console.log('Listening on port', 3030); }); });
Debug
Known issues
deprecatedPackage is no longer actively maintained; consider using modern frameworks like Next.js or Gatsby.
fix
Migrate to a current SSR framework.
affects: >=2.0
gotchaThe build() method must be called before using the middleware to ensure assets are compiled.
fix
Ensure you call site.build() and wait for it to resolve before mounting.
affects: >=2.0
gotchaCustom webpack loaders passed via `webpackLoaders` replace the default loaders entirely.
fix
If you need default loaders, include them in your custom array.
affects: >=2.0
gotchaThe init() method overwrites existing folder structure if called on an existing directory.
fix
Use init() only once on a fresh folder, or manually create the structure.
affects: >=2.0
Errors
Common errors & fixes
Error: Cannot find module 'react-middleware'
Package not installed or not in node_modules.
fix
Run `npm install react-middleware`.
TypeError: ReactMiddleware is not a function
Default import not used correctly in CJS.
fix
Use `const ReactMiddleware = require('react-middleware').default;` or switch to ESM import.
Error: build() is not a function
ReactMiddleware() called incorrectly (maybe missing `new` or object options).
fix
Ensure you call `ReactMiddleware({ base: './site' })` which returns an object with build method.
Upgrade
Version history
2.2.4latest on npm
Audit
Dependencies
reactrequiredpeer dependency for rendering React components
expressoptionalused for server setup and routing
webpackrequiredused internally for asset compilation
Agent activity
2 hits · last 30 days
node
2
Resources
react-middleware — npm install react-middleware · libregistry