
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
react-collider
Advanced tools
Express middleware for isomorphic Express + React apps. Also usable for any NodeJs app without Express.
Check out the example
folder for a working example, including data-fetching from the Dailymotion API.
$ npm install --save react-collider
Simply add the server middleware in your express app, giving your routes as argument.
var express = require('express'),
app = express(),
port = process.env.PORT || 3000,
collider = require('react-collider').server,
routes = require('./routing')
app.use(collider(routes))
app.listen(port, function() {
console.log('Listening on 127.0.0.1:' + port)
})
Similar: call the client module with your routes.
var collider = require('react-collider').client,
routes = require('./routing')
collider(routes)
If your component must fetch some data before being rendered, use a fetchData
static method. It must return a promise.
Example of a simple component:
var Home = React.createClass({
displayName: 'Home',
statics: {
fetchData: function() {
// returns a promise
return getHomeData()
}
},
render: function() {
var videos = getVideoList()
return (
<div>
<h1>Homepage</h1>
{videos}
</div>
)
}
})
When your component includes another component which needs data too, define a getDependencies
static method to return an array of components:
var Sidebar = require('./sidebar'),
Footer = require('./footer')
var Home = React.createClass({
displayName: 'Home',
statics: {
getDependencies: function() {
return [Sidebar, Footer]
}
},
render: function() {
return (
<div>
<Sidebar data={this.props.data.Sidebar} />
<div>
<h1>Homepage</h1>
</div>
<Footer data={this.props.data.Footer} />
</div>
)
}
})
Important: If you're not using es6 to write your components, be sure to define the displayName
of your components. This is necessary for the module to correctly return the data.
If your servers are down and you can't pre-render the pages server-side, your app will still work client side (assuming your API is okay). All you need is to send a basic html file with your app bundled. Check out the example
folder for an example.
You can use react-collider wihtout express. You can simply use it to get the React component to render and the data to use:
var collider = require('react-collider').collider,
routes = require('./routing')
var url = '/video'
// simply provide your routes and the url
collider(routes, url, function(Handler, data) {
var page = React.renderToString(React.createElement(Handler, {data: data}))
})
FAQs
Express middleware for isomorphic express + react apps
The npm package react-collider receives a total of 14 weekly downloads. As such, react-collider popularity was classified as not popular.
We found that react-collider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.