What you’ll learn
- what are environment-related utility functions - what environment-related utility functions are available

Overview
anchor

This article covers a couple of environment-related utility functions that can be used within the Admin application, or, in other words, when developing extensions for the Admin application.

To learn more about extensions in general, please visit the Extensions article.

Available Utility Functions
anchor

The following is a list of available utility functions:

import {
  getApiUrl,
  getGqlApiUrl,
  getHeadlessCmsGqlApiUrl,
  getLocaleCode,
  getTenantId,
  isLocalhost,
} from "@webiny/app-admin"; // Use `@webiny/app` for versions 5.41.3 or older.

// Returns URL of Webiny's backend API.
getApiUrl(); // https://xyz.cloudfront.net

// Returns URL of Webiny's backend GraphQL API.
getGqlApiUrl(); // https://xyz.cloudfront.net/graphql

// Returns URLs of Webiny's backend Headless CMS GraphQL API.
getHeadlessCmsGqlApiUrl(); // { preview: "...", manage: "...", read: "..."}

// Returns locale used on the page.
getLocaleCode(); // en-US

// Returns current tenant.
getTenantId(); // root

// Returns `true` if the application is run on localhost.
isLocalhost(); // true

For versions 5.41.3 or older, instead of the @webiny/app-admin package, please use the @webiny/app package.