Storing Data

A common pattern in SaaS apps is to give each customer a unique subdomain. By default second-level domains are considered internal to your application. (For more info see Defining Internal URLs below)
Say you have your customers login at which then redirects them to You can store the last used subdomain and redirect your users there when they open the app.
// On login to subdomain
if (window.todesktop) {
localStorage.setItem('subdomain', 'yourcustomer');
// When not already on subdomain then redirect to last used subdomain
if (window.todesktop) {
const subdomain = localStorage.getItem('subdomain')
if (subdomain) {
window.location = `https://${subdomain}`
We recommend having a separate javascript app for all of your ToDesktop specific login and importing that conditionally when your app is running as a desktop app.