# Blank Screen with rootPage

**URL:** <https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459>\
**Category:** ionic-v3\
**Created:** [October 10, 2016, 3:59pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459 "2016-10-10T15:59:33Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![candelibas](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@candelibas](https://forum.ionicframework.com/u/candelibas)\
**Post date:** [October 10, 2016, 3:59pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/1 "2016-10-10T15:59:33Z")

</div>

In app.component.ts file:

public rootPage: any;

```
ngOnInit(){
      firebase.auth().onAuthStateChanged((user) => {
        if (user) {
          this.rootPage = TabsPage;
        } else {
          this.rootPage = Login;
        }
      });
  
  }

```

It’s just give me blank page without any console errors.

---

<div class="post-metadata">

**Author:** ![mirkonasato](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirkonasato/32/131398_2.png) [@mirkonasato](https://forum.ionicframework.com/u/mirkonasato)\
**Post date:** [October 10, 2016, 8:48pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/2 "2016-10-10T20:48:18Z")

</div>

You should probably use the [NavController](http://ionicframework.com/docs/v2/api/navigation/NavController/) to navigate from one page to another one.

---

<div class="post-metadata">

**Author:** ![Ellezo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ellezo/32/104261_2.png) [@Ellezo](https://forum.ionicframework.com/u/Ellezo)\
**Post date:** [October 11, 2016, 12:42am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/3 "2016-10-11T00:42:24Z")

</div>

The logic is already correct for setting the root page. Try to call this function inside the constructor and see if it work.

---

<div class="post-metadata">

**Author:** ![ecureuill](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ecureuill/32/102618_2.png) [@ecureuill](https://forum.ionicframework.com/u/ecureuill)\
**Post date:** [October 11, 2016, 12:50am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/4 "2016-10-11T00:50:30Z")

</div>

There is an issue opened for this, see

> [@Page coming as blank after login in Ionic 2 RC0](https://forum.ionicframework.com/t/page-coming-as-blank-after-login-in-ionic-2-rc0/65077):
>
> I have a login screen as my Root page in my Ionic 2 RC0 app. Once the username and password are validated I am setting HomePage as my Root page in the app. I see in the log the constructor of the page is getting called but the screen is coming as blank. Below is the code: WelcomePage.ts @Component({ templateUrl: 'welcome.html', }) export class WelcomePage { constructor(public nav: NavController, public loginService : LoginService, public labelAndAlerts : AppLa…

---

<div class="post-metadata">

**Author:** ![candelibas](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@candelibas](https://forum.ionicframework.com/u/candelibas)\
**Post date:** [October 11, 2016, 2:10pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/5 "2016-10-11T14:10:36Z")

</div>

I already checked it, still no solution.

---

<div class="post-metadata">

**Author:** ![ecureuill](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ecureuill/32/102618_2.png) [@ecureuill](https://forum.ionicframework.com/u/ecureuill)\
**Post date:** [October 11, 2016, 3:33pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/6 "2016-10-11T15:33:17Z")

</div>

There is a fixe.  
See the discussion in github issue

---

<div class="post-metadata">

**Author:** ![kingofspeed6](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kingofspeed6/32/101723_2.png) [@kingofspeed6](https://forum.ionicframework.com/u/kingofspeed6)\
**Post date:** [October 13, 2016, 7:05am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/7 "2016-10-13T07:05:15Z")

</div>

Hello, i always get this problem today  
how i can get that fixe ?  
thanks so much

---

<div class="post-metadata">

**Author:** ![kingofspeed6](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kingofspeed6/32/101723_2.png) [@kingofspeed6](https://forum.ionicframework.com/u/kingofspeed6)\
**Post date:** [October 13, 2016, 9:01am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/8 "2016-10-13T09:01:00Z")

</div>

I just figured out, thats the crosswalk’s problem, when i remove crosswalk, everything is fine

---

<div class="post-metadata">

**Author:** ![candelibas](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@candelibas](https://forum.ionicframework.com/u/candelibas)\
**Post date:** [October 13, 2016, 10:48am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/9 "2016-10-13T10:48:24Z")

</div>

> [@kingofspeed6](#):
>
> uch

I don’t think that it’s just about crosswalk. It happened to me without crosswalk.

---

<div class="post-metadata">

**Author:** ![candelibas](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@candelibas](https://forum.ionicframework.com/u/candelibas)\
**Post date:** [November 5, 2016, 1:08pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/10 "2016-11-05T13:08:18Z")

</div>

Still happening in rc.2

---

<div class="post-metadata">

**Author:** ![joshmorony](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/joshmorony/32/117695_2.png) [@joshmorony](https://forum.ionicframework.com/u/joshmorony)\
**Post date:** [November 5, 2016, 1:30pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/11 "2016-11-05T13:30:15Z")

</div>

You shouldn’t conditionally set the rootPage asynchronously. The rootPage is set right away, but if some asynchronous operation is performed first (like checking if a user is authenticated) before determining the rootPage, it’s going to cause issues.

I handle this by setting the root page to the login page, and then on the login page trigger the authentication check within `ionViewDidLoad` and once it completes, use `setRoot` to change the page (if necessary).

---

<div class="post-metadata">

**Author:** ![candelibas](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@candelibas](https://forum.ionicframework.com/u/candelibas)\
**Post date:** [November 5, 2016, 1:49pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/12 "2016-11-05T13:49:16Z")

</div>

Hey Josh,  
Glad to see your answer. I tried your way. But it shows the login page about 2-3 seconds even im logged in. After that, it changes to TabsPage. Also, if I logout and turn to Login page with setRoot(), I see tabs on my login page. This was pretty weird.

So I had to create another page which is called “initial-page”. All this does checking authentication and setRoot to Login or TabsPage. It works but it increases boot time. So I’m still looking for the best way.

---

<div class="post-metadata">

**Author:** ![joshmorony](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/joshmorony/32/117695_2.png) [@joshmorony](https://forum.ionicframework.com/u/joshmorony)\
**Post date:** [November 5, 2016, 2:14pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/13 "2016-11-05T14:14:35Z")

</div>

Sure, something needs to display during the 2-3 seconds it takes to do the check. I still like to stick to just doing it with the login page. Usually I will just throw up a “Authenticating…” loading overlay whilst it performs the check, if they are logged in then swap pages, if not then just hide the overlay.

---

<div class="post-metadata">

**Author:** ![sunnyahoo](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sunnyahoo](https://forum.ionicframework.com/u/sunnyahoo)\
**Post date:** [June 8, 2017, 8:29am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/14 "2017-06-08T08:29:35Z")

</div>

Not setting rootPage conditionally worked great! Thanks a lot Josh and also candelibas! You guys saved my life!

---

<div class="post-metadata">

**Author:** ![jonaslimads](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonaslimads](https://forum.ionicframework.com/u/jonaslimads)\
**Post date:** [November 5, 2017, 1:14pm UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/15 "2017-11-05T13:14:00Z")

</div>

A good to way to ensure that a conditional rootPage is shown is using ChangeDetectorRef [https://angular.io/api/core/ChangeDetectorRef](https://angular.io/api/core/ChangeDetectorRef)

For example:

```auto
constructor(..., cdr: ChangeDetectorRef, ...) {
... some conditions
this.rootPage = 'MyPage';
this.cdr.detectChanges();

```

---

<div class="post-metadata">

**Author:** ![krrskl](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/krrskl/32/120347_2.png) [@krrskl](https://forum.ionicframework.com/u/krrskl)\
**Post date:** [July 9, 2018, 2:19am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/16 "2018-07-09T02:19:00Z")

</div>

Hola, yo solucioné ese problema de que la aplicación se quedaba con la pantalla en blanco agregando esta línea de código en la página root, en mi caso la página de LOGIN es mi root y justo allí es donde válido si hay una sesión iniciada.

```auto
this.navCtrl.setRoot(InicioPage, {}, {animate: true, direction: 'forward', duration: 1000});

```

---

<div class="post-metadata">

**Author:** ![coxad27](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/coxad27/32/120846_2.png) [@coxad27](https://forum.ionicframework.com/u/coxad27)\
**Post date:** [October 28, 2018, 8:25am UTC](https://forum.ionicframework.com/t/blank-screen-with-rootpage/66459/17 "2018-10-28T08:25:36Z")

</div>

Hi Josh. I came here while trying to figure out why (or how) I might be able to control the window.open() whilst trying to get token back from a call to OAuth API. It shows my OAuth content fine, but when it returns/redirects to my localhost:8100/null instead of something like localhost/#/some-page Any ideas?
