CorvidReference

wix-site

The wix-site module contains functionality for obtaining information about your site and its pages.

To use the site module, import wixSite from the wix-site module:

   import wixSite from 'wix-site';

The APIs in wix-site can only be used in front-end code.

Table of Contents

PROPERTIES

?
Store values associated with an object.
currencyGets a code representing the site's currency.
currentPageGets information about the current page or lightbox.
languageGets a code representing the site's language.
regionalSettingsGets the site's regional settings.
revisionGets the site revision ID.
timezoneGets the site's timezone.

FUNCTIONS

?
Perform actions on an object.
getSiteStructure( )Returns information about the site's pages, prefixes, and lightboxes.
routerSitemap( )Returns the sitemap for a router or dynamic page prefix.

OBJECTS

?
Objects used when setting, getting, or calling the properties and methods listed above.
PrefixAn object that contains information about the site's prefixes.
SiteStructureAn object that contains information about the site's pages, prefixes, and lightboxes.
StructureLightboxAn object that contains information about a lightbox on the site.
StructurePageAn object that contains information about a page on the site.

FAQ

    How are dynamic pages listed in the site structure?
    Does the site structure include nested pages?
    Does site structure return lightboxes?
    What's the difference between the 'fetch()' and 'getJSON()' functions?
    How do I make a CORS request?
    Can I fetch resources that start with http and not https?

currency

Gets a code representing the site's currency.

Description

The retrieved currency code corresponds to the currency that has been entered in the General Info section of your site's Dashboard.

The currency is used your site, apps (e.g. Wix Stores, Wix Bookings), and other Wix features.

Syntax

get currency(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the site's currency

import wixSite from 'wix-site';

// ...

let currency = wixSite.currency; // "USD"

currentPage

Gets information about the current page or lightbox.

See Also

getSiteStructure( )

Syntax

get currentPage(): StructurePage | StructureLightbox

Examples

Get information about the current page

import wixSite from 'wix-site';

// ...

let current = wixSite.currentPage;

/*
 *  {
 *    "name": "Home",
 *    "type": "static",
 *    "url": "/home",
 *    "isHomePage": true
 *  }
 */

Get information about the current lightbox

import wixSite from 'wix-site';

// ...

let current = wixSite.currentPage;

/*
 *  {
 *    "name": "Welcome (Full Screen)"
 *    "type": "lightbox"
 *  }
 */

language

Gets a code representing the site's language.

Description

The retrieved language code corresponds to the language that has been entered in the General Info section of your site's Dashboard.

The language is used your site, apps (e.g. Wix Stores, Wix Bookings), and other Wix features.

Syntax

get language(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the site's language

import wixSite from 'wix-site';

// ...

let language = wixSite.language; // "en"

regionalSettings

Gets the site's regional settings.

Description

The retrieved regional settings corresponds to the regional settings that has been entered in the General Info section of your site's Dashboard.

The regional settings are used to determine how numbers, dates, and currencies are displayed on your site.

Syntax

get regionalSettings(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the site's regionalSettings

import wixSite from 'wix-site';

// ...

let regionalSettings = wixSite.regionalSettings; // "en-us"

revision

Gets the site revision ID.

Description

The site revision ID is a unique identifier for the current revision of your site. Each time you manually save your site or publish your site following a change, a new revision is created.

You can view and manage your site revisions in your Site History. You can use site monitoring to monitor and debug new revisions of your site.

Note

Since publishing your site may change the revision ID, the ID when previewing your site may be different than the ID for the published site.

The site revision ID is guaranteed to be unique, but not meaningful. Therefore, you cannot predict future revision IDs before they are created.

Syntax

get revision(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the site revision ID

import wixSite from 'wix-site';

// ...

let revision = wixSite.revision; // "4x2y"

timezone

Gets the site's timezone.

Description

The retrieved timezone is the timezone that has been entered in the General Info section of your site's Dashboard.

The timezone is used your site, apps (e.g. Wix Stores, Wix Bookings), and other Wix features.

Syntax

get timezone(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the site's timezone

import wixSite from 'wix-site';

// ...

let timezone = wixSite.timezone; // "America/New_York"

getSiteStructure( )

Returns information about the site's pages, prefixes, and lightboxes.

See Also

currentPage

Syntax

function getSiteStructure(): SiteStructure
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
An object that contains information about the site's pages, prefixes, and lightboxes.

Examples

Get information about the site's pages, prefixes, and lightboxes

This example gets the structure of the site with the following in its pages menu:

import wixSite from 'wix-site';

// ...

let structure = wixSite.getSiteStructure();

/*
*  {
*    "pages": [
*      {
*        "name": "Home",
*        "type": "static",
*        "url": "/home",
*        "isHomePage": true
*      },
*      {
*        "name": "Page 1",
*        "type": "static",
*        "url:" /page-1"
*      },
*      {
*        "name": "Page 2",
*        "type": "static",
*        "url": "/page-2"
*      },
*      {
*        "name": "Parent Page",
*        "type": "static",
*        "url": "/parent-page"
*      },
*      {
*        "name": "Child Page",
*        "type": "static",
*        "url": "/child-page"
*      },
*      {
*        "name": "router-page",
*        "type": "template",
*        "prefix": "router"
*      },
*      {
*        "name": "MyCollection (Title)",
*        "type": "template",
*        "prefix": "MyCollection"
*      },
*      {
*        "name": "MyCollection (All)",
*        "type": "template",
*        "prefix": "MyCollection"
*      },
*      {
*        "name": "Dashboard Page",
*        "type": "static"
*      },
*      {
*        "name": "Shop",
*        "type": "template",
*        "url": "/shop",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Product Page",
*        "type": "template",
*        "url": "/product-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Thank You Page",
*        "type": "template",
*        "url": "/thank-you-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Cart",
*        "type": "template",
*        "url": "/cart",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Members",
*        "type": "template",
*        "url": "/members",
*        "applicationId": "14ad9202-3dd3-128a-57bd-e5675fd7e313"
*      }
*    ],
*    "prefixes": [
*      {
*        "name": "router",
*        "type": "router",
*        "prefix": "/router"
*      },
*      {
*        "name": "MyCollection",
*        "type": "dynamicPages",
*        "prefix": "/MyCollection"
*      },
*      {
*        "name": "MyCollection",
*        "type": "dynamicPages",
*        "prefix": "/MyCollection"
*      },
*      {
*        "name": "Shop",
*        "type": "app",
*        "prefix: "/shop",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Product Page",
*        "type": "app",
*        "prefix": "/product-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Thank You Page",
*        "type": "app",
*        "prefix": "/thank-you-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Cart",
*        "type": "app",
*        "url": "/cart",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Members",
*        "type": "app",
*        "prefix": "/members",
*        "applicationId": "14ad9202-3dd3-128a-57bd-e5675fd7e313"
*      }
*    ],
*    "lightboxes": [
*      {
*        "name": "Welcome (Full Screen)"
*      }
*    ]
*  }
*/

routerSitemap( )

Returns the sitemap for a router or dynamic page prefix.

Description

The routerSitemap() function returns a Promise that resolves to a list of WixSitemapEntry objects. Each WixSitemapEntry includes information about a page, such as its URL, title, and name.

A sitemap is used by search engines to find the links to the site's pages.

Syntax

function routerSitemap(routerPrefix: string): Promise<Array<WixRouterSitemapEntry>>
PARAMETERS
?
Values that you pass to a function.
routerPrefix
string
The prefix of the router to get the sitemap for.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<Array<WixRouterSitemapEntry>>

Fulfilled - A list of sitemap entries. Rejected - The error that caused the rejection.

Examples

Get the sitemap for a prefix

import wixSite from 'wix-site';

// ...

wixSite.routerSitemap("routerPrefix")
  .then( (routerSitemap) => {
    let sitemap = routerSitemap;
  } );

/*
 * sitemap:
 *
 * [
 *   {
 *   	"url": "Ash",
 *   	"lastModified": null,
 *   	"changeFrequency": "",
 *   	"priority": null,
 *   	"title": "Ash Stowe",
 *   	"pageName": "Ash's Page"
 *   },
 *   {
 *   	"url": "Aiden",
 *   	"lastModified": null,
 *   	"changeFrequency": "",
 *   	"priority": null,
 *   	"title": "Aiden Johnson",
 *   	"pageName": "Aiden's page"
 *   },
 *   {
 *   	"url": "Jess",
 *   	"lastModified": null,
 *   	"changeFrequency": "",
 *   	"priority": null,
 *   	"title": "Jess White",
 *   	"pageName": "Jess's page"
 *   },
 *   {
 *   	"url": "Morgan",
 *   	"lastModified": null,
 *   	"changeFrequency": "",
 *   	"priority": null,
 *   	"title": "Morgan James",
 *   	"pageName": "Morgan's Page"
 *   }
 * ]
 */

Prefix

An object that contains information about the site's prefixes.

Description

A site's routers, dynamic pages, and app pages all have prefixes.

See Also

SiteStructure, currentPage, getSiteStructure( )

Syntax

type Prefix = {
  name: string
  type: string
  prefix: string
  applicationId: string
}
MEMBERS
?
The properties of an object.
name
string
The name of the prefix.
type
string
The type of the prefix: "dynamicPages", "router", or "app".
prefix
string
The prefix.
applicationId(Optional)
string
If the prefix is an app's prefix, the applicationId property is the app's ID.

Examples

Get information about the site's prefixes

This example gets the prefixes of the site with the following in its pages menu:

import wixSite from 'wix-site';

// ...

let structure = wixSite.getSiteStructure();
let prefixes = structure.prefixes;

/*
 *  prefixes:
 *  [
 *    {
 *      "name": "router",
 *      "type": "router",
 *      "prefix": "/router"
 *    },
 *    {
 *      "name": "myCollection",
 *      "type": "dynamicPages",
 *      "prefix": "/myCollection"
 *    },
 *    {
 *      "name": "myCollection",
 *      "type": "dynamicPages",
 *      "prefix": "/myCollection"
 *    },
 *    {
 *      "name": "Shop",
 *      "type": "app",
 *      "prefix": "/shop",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Product Page",
 *      "type": "app",
 *      "prefix": "/product-page",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Thank You Page",
 *      "type": "app",
 *      "prefix": "/thank-you-page",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Cart",
 *      "type": "app",
 *      "prefix": "/cart",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Members",
 *      "type": "app",
 *      "prefix": "/members",
 *      "applicationId": "14ad9202-3dd3-128a-57bd-e5675fd7e313"
 *    }
 *  ]
 */

SiteStructure

An object that contains information about the site's pages, prefixes, and lightboxes.

Description

The SiteStructure object is a flattened representation of the site. Use the getSiteStructure() function to get the site's SiteStructure object. The structure does not include the headers and links from the site's Pages menu.

See Also

getSiteStructure( )

Syntax

type SiteStructure = {
  pages: Array<StructurePage>
  prefixes: Array<Prefix>
  lightboxes: Array<StructureLightbox>
}
MEMBERS
?
The properties of an object.
pages
The pages of the site.
prefixes
Array<Prefix>
The prefixes of the site's routers and dynamic pages.
lightboxes
The site's lightboxes.

Examples

Get information about the site's pages, prefixes, and lightboxes

This example gets the structure of the site with the following in its pages menu:

import wixSite from 'wix-site';

// ...

let structure = wixSite.getSiteStructure();

/*
*  {
*    "pages": [
*      {
*        "name": "Home",
*        "type": "static",
*        "url": "/home",
*        "isHomePage": true
*      },
*      {
*        "name": "Page 1",
*        "type": "static",
*        "url:" /page-1"
*      },
*      {
*        "name": "Page 2",
*        "type": "static",
*        "url": "/page-2"
*      },
*      {
*        "name": "Parent Page",
*        "type": "static",
*        "url": "/parent-page"
*      },
*      {
*        "name": "Child Page",
*        "type": "static",
*        "url": "/child-page"
*      },
*      {
*        "name": "router-page",
*        "type": "template",
*        "prefix": "router"
*      },
*      {
*        "name": "MyCollection (Title)",
*        "type": "template",
*        "prefix": "MyCollection"
*      },
*      {
*        "name": "MyCollection (All)",
*        "type": "template",
*        "prefix": "MyCollection"
*      },
*      {
*        "name": "Dashboard Page",
*        "type": "static"
*      },
*      {
*        "name": "Shop",
*        "type": "template",
*        "url": "/shop",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Product Page",
*        "type": "template",
*        "url": "/product-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Thank You Page",
*        "type": "template",
*        "url": "/thank-you-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Cart",
*        "type": "template",
*        "url": "/cart",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Members",
*        "type": "template",
*        "url": "/members",
*        "applicationId": "14ad9202-3dd3-128a-57bd-e5675fd7e313"
*      }
*    ],
*    "prefixes": [
*      {
*        "name": "router",
*        "type": "router",
*        "prefix": "/router"
*      },
*      {
*        "name": "MyCollection",
*        "type": "dynamicPages",
*        "prefix": "/MyCollection"
*      },
*      {
*        "name": "MyCollection",
*        "type": "dynamicPages",
*        "prefix": "/MyCollection"
*      },
*      {
*        "name": "Shop",
*        "type": "app",
*        "prefix: "/shop",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Product Page",
*        "type": "app",
*        "prefix": "/product-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Thank You Page",
*        "type": "app",
*        "prefix": "/thank-you-page",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Cart",
*        "type": "app",
*        "url": "/cart",
*        "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
*      },
*      {
*        "name": "Members",
*        "type": "app",
*        "prefix": "/members",
*        "applicationId": "14ad9202-3dd3-128a-57bd-e5675fd7e313"
*      }
*    ],
*    "lightboxes": [
*      {
*        "name": "Welcome (Full Screen)"
*      }
*    ]
*  }
*/

StructureLightbox

An object that contains information about a lightbox on the site.

See Also

SiteStructure, currentPage, getSiteStructure( )

Syntax

type StructureLightbox = {
  name: string
}
MEMBERS
?
The properties of an object.
name
string
The name of the lightbox.

Examples

Get information about the current lightbox

import wixSite from 'wix-site';

// ...

let current = wixSite.currentPage;

/*
 *  {
 *    "name": "Welcome (Full Screen)"
 *    "type": "lightbox"
 *  }
 */

Get information about the site's lightboxes

This example gets the lightboxes of the site with the following in its pages menu:

import wixSite from 'wix-site';

// ...

let structure = wixSite.getSiteStructure();
let lightboxes = structure.lightboxes;

/*
 *  lightboxes:
 *
 *  [
 *    {
 *       "name": "Welcome (Full Screen)"
 *    }
 *  ]
 */

StructurePage

An object that contains information about a page on the site.

Description

The StructurePage object represents a page in the site. The page can be a regular page, dynamic page, router page, or page from an app.

See Also

SiteStructure, getSiteStructure( )

Syntax

type StructurePage = {
  name: string
  type: string
  url: string
  applicationId: string
  prefix: string
  isHomePage: boolean
}
MEMBERS
?
The properties of an object.
name
string
The of the page.
type
string
The type of the page: "static" or "template".
url(Optional)
string
The URL of the page. If the page is a static page the url property is the page's SEO URL.
applicationId(Optional)
string
If the page is an app page, the applicationId property is the app's ID.
prefix(Optional)
string
If the page is a router or dynamic page, the prefix property is the page's prefix.
isHomePage(Optional)
boolean
If the page is the Home page, isHomePage is true. Otherwise, it does not exist.

Examples

Get information about the current page

import wixSite from 'wix-site';

// ...

let current = wixSite.currentPage;

/*
 *  {
 *    "name": "Home",
 *    "type": "static",
 *    "url": "/home",
 *    "isHomePage": true
 *  }
 */

Get information about the site's pages

This example gets the pages of the site with the following in its pages menu:

import wixSite from 'wix-site';

// ...

let structure = wixSite.getSiteStructure();
let pages = structure.pages;

/*
 *  pages:
 *  [
 *    {
 *      "name": "Home",
 *      "type": "static",
 *      "url": "/home",
 *      "isHomePage": true
 *    },
 *    {
 *      "name": "Page 1",
 *      "type": "static",
 *      "url:" /page-1"
 *    },
 *    {
 *      "name": "Page 2",
 *      "type": "static",
 *      "url": "/page-2"
 *    },
 *    {
 *      "name": "Parent Page",
 *      "type": "static",
 *      "url": "/parent-page"
 *    },
 *    {
 *      "name": "Child Page",
 *      "type": "static",
 *      "url": "/child-page"
 *    },
 *    {
 *      "name": "router-page",
 *      "type": "template",
 *      "prefix": "router"
 *    },
 *    {
 *      "name": "MyCollection (Title)",
 *      "type": "template",
 *      "prefix": "MyCollection"
 *    },
 *    {
 *      "name": "MyCollection (All)",
 *      "type": "template",
 *      "prefix": "MyCollection"
 *    },
 *    {
 *      "name": "Dashboard Page",
 *      "type": "static"
 *    },
 *    {
 *      "name": "Shop",
 *      "type": "template",
 *      "url": "/shop",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Product Page",
 *      "type": "template",
 *      "url": "/product-page",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Thank You Page",
 *      "type": "template",
 *      "url": "/thank-you-page",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Cart",
 *      "type": "template",
 *      "url": "/cart",
 *      "applicationId": "1380b703-ce81-ff05-f115-39571d94dfcd"
 *    },
 *    {
 *      "name": "Members",
 *      "type": "template",
 *      "url": "/members",
 *      "applicationId": "14ad9202-3dd3-128a-57bd-e5675fd7e313"
 *    }
 *  ]
 */