I am new to Meteor. What I want is when I go to the page if the user is logged in, show "Logged In" and if not show "Not Logged In", here the is snippet I tried that,
{{#if currentUser}} Logged In {{else}} Not Logged In {{/if}}
So when a "signed up" user comes I expect, directly showing "Logged In". But what happen is it shows "Not Logged In" first and then after about a second shows "Logged In". How to avoid this?
Thanks in advance
That's because the user is still logging in. I recommend you define a helper as such:
Template.myTemplateName.helpers({
authenticated: function() {
return Meteor.user() || Meteor.loggingIn();
}
})
and then use it like you want:
{{#if authenticated}} Logged In {{else}} Not Logged In {{/if}}