Overview

UIX

Utility Functions

The redirect function

It is recommended to use the redirect utility function when redirecting to a new page, instead of setting globalThis.location.href directly.

The redirect function guarantees that all scheduled DATEX updates are sent before leaving the current page. This prevents inconsistencies for shared pointer values:

// safe navigation to '/home'
redirect('/home'); 

This is equivalent to

// wait until all scheduled DATEX updates are sent
await Datex.Runtime.synchronized; 
// navigate to "/home"
globalThis.location.href = '/home';

The redirect function is available in the global scope by default, but can also be imported from "uix/utils/window-apis.ts".

Note

The redirect function can only be used on the frontend. If you want to redirect during backend routing, use the provideRedirect function

Did this doc help you?

Privacy Policy

Help us improving our docs

Our documentations are fully open source. Something is wrong or unclear?

Make a contribution