Gets which mode the site is currently being viewed in.
The viewMode
property gets either:
"Preview"
: When previewing the site using the Preview button in the editor."Site"
: When viewing the published site."Editor"
: When viewing a Wix Blocks built widget in the editor.function viewMode(): Promise<string>;
import { createClient } from "@wix/sdk";
import { site } from "@wix/site";
import { window as wixWindow } from "@wix/site-window";
const wixClient = createClient({
host: site.host(),
modules: { wixWindow },
});
// ...
let viewMode = await wixClient.wixWindow.viewMode(); // "Site"
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.