From 6d09566ba702483c116ea137cfddfa6b7f688810 Mon Sep 17 00:00:00 2001 From: Neal Shah <30693865+ProgrammerIn-wonderland@users.noreply.github.com> Date: Mon, 21 Jul 2025 17:02:46 -0400 Subject: [PATCH] Allow multipage apps in puterjs (#1368) * Allow multipage apps in puterjs * Don't error on browsers which dont support sessionStorage --- src/puter-js/src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/puter-js/src/index.js b/src/puter-js/src/index.js index 84f490264..11fb46dd1 100644 --- a/src/puter-js/src/index.js +++ b/src/puter-js/src/index.js @@ -126,12 +126,13 @@ export default globalThis.puter = (function() { context.services = this.services; // Holds the query parameters found in the current URL - let URLParams = new URLSearchParams(globalThis.location?.search); + let URLParams = new URLSearchParams(globalThis.sessionStorage?.getItem("puter_search_params") || globalThis.location?.search); // Figure out the environment in which the SDK is running - if (URLParams.has('puter.app_instance_id')) + if (URLParams.has('puter.app_instance_id')) { + globalThis.sessionStorage?.setItem("puter_search_params", globalThis.sessionStorage?.getItem("puter_search_params") || globalThis.location?.search) this.env = 'app'; - else if(globalThis.puter_gui_enabled === true) + } else if(globalThis.puter_gui_enabled === true) this.env = 'gui'; else if (globalThis.WorkerGlobalScope) { if (globalThis.ServiceWorkerGlobalScope) {