Skip to main content

Client lifecycle

Root controls when your App's client starts, when it stops, and when it gets reloaded. This article explains the different phases of the client lifecycle and how Root manages the client for you.

Container model

The client side of your App runs inside a Chromium browser tab, which itself runs inside the Root native client.

Network connection

Your App’s client doesn't connect to the internet directly. All network traffic goes through the Root native client. Root watches the network connection. If it's lost, Root takes over and handles reconnection. Your client doesn't need to manage it.

What is the client lifecycle?

The client lifecycle is the set of states your App's client moves through while running inside the Root native client. Root decides when to launch, suspend, or reload the client based on user actions and network conditions.

There are only two states: NotRunning and Running. The important concepts are what causes your client to transition between the two.

Normal startup

The user selects the App’s channel. Root creates a new Chromium tab and runs your client code.

Inactivity

If the user stops interacting with the App for several minutes, Root will stop your client and unload the Chromium tab. This helps conserve system resources.

Connectivity loss

If the Root native client loses its network connection, it will unload your client and move it to the NotRunning state. Root will keep trying to reconnect. Once the connection is restored, it will automatically reload your client.

Summary

  • Your client runs inside a Chromium tab managed by the Root native client.
  • Root starts the client when the user selects your App's channel.
  • The client is unloaded if the user is inactive or the network goes down.
  • When the network comes back, Root reloads your client automatically.
  • You don’t need to manage the browser tab, network status, or reconnect logic, Root handles it for you.