meteor/guide

Using React Router with Accounts

lorensr opened this issue · 2 comments

From #625 (comment)

Second problem is that in the guide I can't really find how to properly use React-router with the accounts system. It probably would be a big help for everyone if there was a clear example or maybe a next step in the Todo App with React explaining it.
Also you can't use AppContainer in the same way as in FlowRouter. Because in the above example AppContainer wont be like a 'layout' component.

I found a couple of authentication examples online: The Meteor Chef and one on StackOverflow but the one from StackOverflow uses onEnter and that's not React-router v4 but v3. There are more examples but they're using older version of react-router.

Here's an idea on how to do it with react router 4:

https://gist.github.com/lucnat/643988451c783a8428a2811dbea3d168

  • public components are visible by everyone - they use the PublicLayout
  • authenticated components are visible by authenticated users only - they use the AuthenticatedLayout

We could have an arbitrary number of layouts. In the example above, there are two layouts - each with it's own navbar.

I'm closing this issue because it's too old.

We are going to make many updates to the guide in the next weeks and it's better to focus on issues with recent activity. If you think this issue is still relevant please open a new one.