# Dynamic rootPage based on Auth.isAuthenticated()

**URL:** <https://forum.ionicframework.com/t/dynamic-rootpage-based-on-auth-isauthenticated/71273>\
**Category:** ionic-v3\
**Created:** [November 24, 2016, 3:32pm UTC](https://forum.ionicframework.com/t/dynamic-rootpage-based-on-auth-isauthenticated/71273 "2016-11-24T15:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramon](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ramon/32/75852_2.png) [@ramon](https://forum.ionicframework.com/u/ramon)\
**Post date:** [November 24, 2016, 3:32pm UTC](https://forum.ionicframework.com/t/dynamic-rootpage-based-on-auth-isauthenticated/71273/1 "2016-11-24T15:32:55Z")

</div>

Hi,

Initially, this issue was a bug report trying to dynamically set the root page for my application. Now, I have already solved.

Perhaps this example will be useful to someone:

```
import {Component} from '@angular/core';
import {Platform} from 'ionic-angular';
import {StatusBar, Splashscreen} from 'ionic-native';
import {HomePage} from '../pages/home/home';
import {LoginPage} from "../pages/login/login";
import {Auth} from "@ionic/cloud-angular";

@Component({
    template: `<ion-nav [root]="rootPage"></ion-nav>`
})
export class MyApp {
    public rootPage;

    constructor(platform: Platform, public auth: Auth) {
        platform.ready().then(() => {
            StatusBar.styleDefault();

            if (this.auth.isAuthenticated()) {
                this.rootPage = HomePage;
            } else {
                this.rootPage = LoginPage;        
            }   
            Splashscreen.hide();     
        });
    } 
}

```

Is this the correct way to get it work?

---

<div class="post-metadata">

**Author:** ![rahimka91](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rahimka91/32/119749_2.png) [@rahimka91](https://forum.ionicframework.com/u/rahimka91)\
**Post date:** [June 1, 2018, 4:42am UTC](https://forum.ionicframework.com/t/dynamic-rootpage-based-on-auth-isauthenticated/71273/2 "2018-06-01T04:42:39Z")

</div>

I’m not sure this the best way. But, it worked for me.  
Thanks for sharing this.😀
