Pass that value using url query (window.location in the custom code) and use wixLocation.onChange() to receive in the wix page
From wix to custom code use wixWindow.postMessage to send and EventListener(“message” …) on custom code.
I guess you can to create a Custom Element to get the custom code var and sent to page using dispatchEvent( new CustomEvent( ‘my-event’ , { detail: data }));
In the wix page user element.on() event to listen