Hide root navbar using VAR on startup of OSC

Hi,

Is it possible to hide the root navigation bar using a variable at the start when the client connects to the server? I'm testing the following on a brand new blank template with a basic custom module.

Inside my root style > CSS I have the following:

inner > .navigation.main {
  display: #{VAR{displayValue, 0} ? "none" : "flex"};
}

And here is the basic custom module I'm using. I found that "sessionOpened" gets me practically there, as soon as the session opens it hides it. However, it's still visible just barely when the session opens then quickly hides, and was wondering if there is a better place to call the recieve(). I'd like to just have a smooth open for when clients load the template instead of seeing a flash of the navigation bar being hidden. Is this possible?

app.on("sessionOpened", async (data, client) => {
  receive("/SCRIPT", `setVar("root", "displayValue", 1)`)
})

module.exports = {
  init: function () {
    // receive("/SCRIPT", `setVar("root", "displayValue", 1)`)
  },
  unload: function () {
    // receive("/SCRIPT", `setVar("root", "displayValue", 1)`)
  },
  oscInFilter: function (data) {
    return data
  },
  oscOutFilter: function (data) {
    return data
  },
}

Cheers,
DMDComposer

P.S.
I forgot to explain, I'm wanting to use a VAR because I want to toggle the view of the Navbar on and off in the template, just at the start have it be hidden.

Maybe hide it by default in the root's css, and only show it if necessary instead of the opposite.

Thanks Jean!

That worked, it made me realize one of my buttons controlling the navbar visibility was conflicting with my defaults onCreate.

Cheers!