Kadira - Performance Monitoring for Meteor (you should try this)

Instant Login For Meteor With Fast Render

We normally use Fast-Render for rendering the initial page quickly in meteor apps that have public-facing interfaces. But also, Fast-Render can be pretty useful for applications that have both private and public views based on the login state.

For an example, look at the following template.

Meteor Template with Login Status Check

If there is no user logged in, it renders a template called guest, as shown below;

Without Logged In

If there is a logged in user, it renders the dashboard template:

With Logged In

Even when there is a logged in user, the Guest template is always rendered when the browser is loading the application. This is because Meteor gets logged in information only when it’s connected to the DDP server. See the following video to observe this behavior:

This situation applies, too, if you are routing based on the user status or displaying certain content by checking the user status with a template helper.

Fast-Render Is The Cure

It’s simple—all you have to do is add Fast-Render or, if you already have it, update to the newest version. If there is a logged in user, Meteor will render the template for the logged in user directly—it will never render the Guest template on the screen.

Watch the following video to see how this works:

That’s what I call Instant Login.

How Is This Possible?

Meteor’s accounts-base package has a very special publication which is implemented as a null publication – that sends logged in user information to the client.

If the publication’s name is null, it is automatically subscribed when the DDP connection is established.

Fast-Render looks for all the null publications and sends all their documents to the client with the initial HTML. So, Fast-Render really can fix the above mentioned issue. To experience Instant Login, add Fast-Render to your project with mrt add fast-render – it just works.