Meteor 1.3 Flow Router vs React Router

Hi I’m part of the old Blaze-FR crowd and would like to update to React to keep my projects as future proof as possible (yes, impossible right?). It’s fairly clear that Blaze is being abandoned for React and it’s time to adapt to the next wave of changes. Meteor 1.3 looks like it’s going to support react meteor data but there’s still no built in support for routing. Right now the community has two major options Flow Router and React Router. What do you guys think currently looks like the best one to use considering MDG’s plans for 2016?

1 Like

I chose the Flow Router route, because it seemed like it had a more extensive API, hooks, etc. React Router seems very pared down and I didn’t see any way to do hooks/triggers, and really half the stuff Flow does.

ReactRouter, just because it is the most “react way” of the major JS community. But a router is a fairly easy part of an application to replace, so I would just pick now what comes most easiest to you.

2 Likes

Right now there is a problem with ReactLayout when used with react imported from NPM.
I’ll publish a version of react-layout to NPM within this week.

1 Like

Exactly. What’s work easy for you. Use it.

1 Like

Read this… Blaze is not being abandoned!

1 Like

I’d pick FlowRouter because 1) it’ll be an easier transition and 2) it’s what @arunoda is using ; )

FR can also receive Meteor-specific improvements, while RR will always be Meteor-agnostic. That being said yeah, it shouldn’t be that hard to switch it out for RR if you ever feel the need to.

3 Likes

Just to illustrate this point with one specific example, if you define a ROOT_URL with a subpath, as in:

$ ROOT_URL='http://example.com/subpath/' meteor

FlowRouter will handle the subpath/ transparantly by prefixing all routes with it. These little integration details are very valuable and a clear advantage for Meteor packages.

5 Likes

Hey, what’s the status on this and what exactly were the problems you encountered? I got very cryptic errors as soon as I installed flow-router and react-layout. Just checking to see if my errors are related to this.

Flow router works perfectly with React. Only thing is that if you are using react from npm than you need to use react-mounter https://github.com/kadirahq/react-mounter instead of ReactLayout. If you are using the react package from MDG you can still use ReactLayout but with 1.3 i think MDG will abandon the package approach for react.

you can use neither, and just render your router, and let it handle the layouting with nested routes. I prefere this approach.

import React from 'react'
import ReactDOM from 'react-dom'
import { Router, browserHistory, Route, IndexRoute } from 'react-router'

import Layout from './layout.jsx'
import Home from './home.jsx'
import NotFound from './notFound.jsx'

Meteor.startup(() => ReactDOM.render(
    <Router history={browserHistory}>
        <Route path='/' component={Layout}>
            <IndexRoute component={Home}/>
            <Route path='*' component={NotFound}/>
        </Route>
    </Router>,
document.getElementById('app'))
1 Like