meteor Meteor + React + ReactRouter Step 3- Add Accounts


Example

If necessary, change to your project directory cd MyAwesomeProject

1- Add accounts packages: meteor add accounts-base accounts-password react-meteor-data

2- Add the routes to login and signup pages in imports/startup/Routes.jsx The render() method will be as follows:

  render() {
    return (
      <Router history={ browserHistory }>
        <Route path="/" component={ App }>
          <IndexRoute name="index" component={ Index }/>
          <Route name="login" path="/login" component={ Login }/>
          <Route name="signup" path="/signup" component={ Signup }/>
          <Route name="users" path="/users" component={ Users }/>
          <Route name="editUser" path="/users/:userId" component={ EditUser }/>
          <Route path="*" component={ NotFound }/>
        </Route>
      </Router>
    );
  }

Note:

  • I'm skipping some other files that you will need, to make things shorter. Specifically, check imports/startup/server/index.js imports/ui/layouts/{App,NavBar}.jsx and import/ui/pages/{Login,Signup,Users,EditUser}.jsx

  • You can view a full example in https://github.com/rafa-lft/Meteor_React_Base. Look for tag Step3_Accounts