Search code examples
meteormeteor-blazemeteor-accountsmeteor-helper

Meteor template: What's the simplest way to check if a user is logged in?


I'm using Meteor's accounts-ui. Is there a way to check if the user is logged in on the template without writing custom helper code?

Pseudo code:

{{#if userIsLoggedIn }}
    You're logged in
{{/if}}

If not, what's the cleanest, most idiomatic way of doing it?

I only care about client-side here.

Thanks.


Solution

  • Simple answer: check if the currentUser object exists.

    {{#if currentUser }}
      You're logged in
    {{/if}}
    

    Yes, it is a default helper, no need to write anything else!