Meteor.user().profile not available in my routes.js react-router file


I’m finding that Meteor.user().profile is almost never ready in any of my render functions. I am also having trouble using it in my onEnter={} stuff in react-router. Meteor.userId() seems to work but no luck with meteor.user.profile() when refreshing the window…


You forgot to publish Meteor.user().profile


Generally speaking the data for the current user can take a few hundred ms to become available after the page first loads. This is completely normal. You have a couple options to mitigate the issues cause by this.

  1. Wait for the data to become ready in some way.
  2. Add meteorhacks:fast-render to your app to push down the user information with the initial html request


Does the fast-render package work with react-router or is it tied to flow-router?


I don’t believe it works off the shelf with react-router. That being said if you use the react-router-ssr package to do server side rendering, it uses fast render.


A meteor user will be in one of three potential states.

  1. Logged In
  2. Logging In
  3. Logged Out

Even with something like fast-render the browser will still have to go through the process of logging in which means that your publications wont be able to be ready until after you have successfully logged in.

A simple ternary check is the simplest solution to this issue IMO.

return Meteor.user().profile ? Meteor.user() : {}

This is particularly useful in Containers where you can check to make sure that your user has logged in and your subscriptions are ready. Then when you pass the user object as a prop you can be sure that you always have the data that you expect to have.

So fast render can use accounts but there are some security concerns see more here:

Canonical Way of Accessing Meteor.user() on client in React?