Skip to main content

Navigation Flow

tramvai router is universal, and work both on server and client sides. But navigation flow is different for all environments and router modules. Also, router has it is own lifecycle, but this flow is embedded in commandLineRunner lifecycle.

Server navigation

At server-side, router navigation will be executed at resolve_user_deps command. Router hooks and guards will be launched in the process:

Diagram

info

Router will run page actions at resolve_page_deps stage.

Client initialization

After page load, router rehydration will be executed at customer_start command. Only guards will be launched in the process:

Diagram

info

Router will run page actions (failed on server or client-side only) at clear stage.

Client SPA navigation

All client navigations with SPA router have a lifecycle, similar to server-side flow. Router hooks and guards will be launched in the process:

Diagram

info

Router will run commandLineRunner stages resolve_user_deps, resolve_page_deps and spa_transition sequentially at beforeNavigate hook, and stage after_spa_transition on afterNavigate hook.

And as you can see, actions behaviour depends on SPA actions mode. This mode allows you to control when to execute actions - before target page rendering or after. More information about SPA Mode in Documentation how to change SPA actions mode

Client NoSPA navigation

This flow is simple - just a hard reload for any navigations:

Diagram