@atlaskit/atlassian-context

中文文档
2.0.0发布于 2026/09/24Apache-2.0TypeScriptESM + CJS近 30 天下载 559.7万

Provides perimeter-specific URL resolution and helps identify which environment a product is running in.

原始使用文档
文档目录18 节
  1. Ownership
  2. Installation
  3. Prerequisites
  4. Setup
  5. Server Generated HTML
  6. Serverless
  7. API
  8. configure()
  9. getATLContextDomain()
  10. getATLContextUrl()
  11. isFedRamp()
  12. isFedrampModerate()
  13. isIsolatedCloud()
  14. isolatedCloudDomain()
  15. isolationContextId()
  16. getDomainInContext(subdomain, environment)
  17. getUrlForDomainInContext(subdomain, environment)
  18. resolveProvidedUrlByBoundary(urls)

Environment context library

Provides perimeter-specific URL resolution and helps identify which environment a product is running in.

Read more about the original considerations here: https://hello.atlassian.net/wiki/spaces/FEDRAMP/pages/2561199256/UI+Isolation

Ownership

In 2025, ownership of the library was transferred to Regulated Industries. Please reach out to #help-cross-boundary for any help.

Installation

npm install @atlaskit/atlassian-context --save

Prerequisites

NOTE: Skip these pre-requisites if onboarding onto library for the first time in May 2025 onwards. These pre-requisites are for the original configure(), getATLContextDomain(), getATLContextUrl(), and isFedRamp() functions, which be will be deprecated in the nearish future.

In order for @atlaskit/atlassian-context to work correctly window.ATL_CONTEXT_DOMAIN has to be set on the page. Products must either have the data already on window or call configure(), before calling any get*() calls. Otherwise getATLContextDomain() and getATLContextUrl() will use fallbacks and potentially return an uncorrected response.

If using the deprecated isFedRamp() method, also window.UNSAFE_ATL_CONTEXT_BOUNDARY = 'fedramp-moderate' | 'commercial' has to be set on the page. Otherwise, you could potentially serve environments with code that it is not relevant to them.

Setup

NOTE: Skip this setup if onboarding onto library for the first time in May 2025 onwards. Access to window.ATL_CONTEXT_DOMAIN and window.UNSAFE_ATL_CONTEXT_BOUNDARY is only required for the configure(), getATLContextDomain(), getATLContextUrl(), and isFedRamp() functions, which be will be deprecated in the nearish future.

This library must be initialised in order to return the correct results. How it gets initialised will depend on your service. The configuration data may be loaded by any Micros service from Config Registry. For any further help, reach out to #help-config-injector.

⚠️ Warning: window.MICROS_PERIMETER will be replaced by window.UNSAFE_ATL_CONTEXT_BOUNDARY in future iterations - see go-is-fedramp.

Server Generated HTML

Recommended

If your service always generates static HTML, you can leverage window context to correctly configure this library. Consider this Velocity template snippet as an example:

<!-- Assuming your Java service has loaded the appropriate configuration into $domain_config -->

<script nonce="$nonce">
    window.ATL_CONTEXT_DOMAIN = $domain_config.stringify();
</script>

<!-- Assuming your Java service has loaded the micros perimeter into $micros_perimeter.
    NOTE: Only needed if your service uses the isFedRamp function
  -->
<script nonce="nonce">
    window.UNSAFE_ATL_CONTEXT_BOUNDARY = $micros_perimeter.stringify();
</script>

The library will automatically initialise with this configuration if the variable is found. If the config isn’t available it will use fallbacks and potentially return uncorrected values.

Serverless

Discourage: This will regress your apps performance. Your page is no longer serverless, due to its requirement for FedRAMP config. You should move to server-based hosting.

Before render, you must fetch the data

import { configure } from '@atlaskit/atlassian-context';

function init(){
  // get the config from globaledge
  const data = await fetch('https://my.backend.api/_config/domains');

  // tell @atlaskit/atlassian-context about it
  configure(data)

  // and only then run other code / render your page
  ReactDOM.render(<YourApp />, element)
}

If your application is rendered through React SSR, you should ensure you will need to manually invoke the configure() function with the provided data.

API

configure()

Disclaimer: This does not need to be invoked for the isFedrampModerate(), isIsolatedCloud(), isolatedCloudDomain(), isolationContextId(), getDomainInContext(...), and getUrlForDomainInContext(...) functions.

Takes the data, and stores in window.ATL_CONTEXT_DOMAIN for later use.

getATLContextDomain()

Disclaimer: Please use getDomainInContext(subdomain, environment) instead of this function, as the deprecation process for this function will begin in the near future.

Returns the domain for a given Atlassian service. It relies on window.ATL_CONTEXT_DOMAIN be present on the page, in case window.ATL_CONTEXT_DOMAIN is undefined getATLContextDomain() will try to retrieve the value from a list of hardcoded domains, which could be not up to date. The fallback relies on window.UNSAFE_ATL_CONTEXT_BOUNDARY be present on the page, if undefined getATLContextDomain() will fallback to non-fedramp (commercial) value.

import { getATLContextDomain } from '@atlaskit/atlassian-context';

getATLContextDomain('jira'); // jira.atlassian.com OR jira.atlassian-fex.com depending based on environment
getATLContextDomain('confluence'); // confluence.atlassian.com
getATLContextDomain('admin'); // admin.atlassian.com OR admin.atlassian-fex.com

getATLContextUrl()

Disclaimer: Please use getUrlForDomainInContext(subdomain, environment) instead of this function, as the deprecation process for this function will begin in the near future.

Returns the full url for a given Atlassian service. Being based off getATLContextDomain, it relies on window.ATL_CONTEXT_DOMAIN be present on the page, otherwise getATLContextDomain will try to retrieve the value from a list of hardcoded domains, which could be not up to date and potentially fallback to non-fedramp (commercial) value.

getATLContextUrl() detects browser protocol (http/https) and applies it to domain.

import { getATLContextUrl } from '@atlaskit/atlassian-context';

getATLContextUrl('jira'); // https://jira.atlassian.com OR https://jira.atlassian-fex.com depending based on environment
getATLContextUrl('confluence'); // https://confluence.atlassian.com
getATLContextUrl('admin'); // https://admin.atlassian.com OR https://admin.atlassian-fex.com

isFedRamp()

Disclaimer: Please use isFedrampModerate() instead of this function, as the deprecation process for this function will begin in the near future.

Caution: Consider Alternatives Use of this function is not recommended as a long term solution, as it creates an assumption there are no other isolated environments than just FedRAMP Moderate. You are encouraged to consider alternate solutions, such as Statsig or environment configuration, that don’t require creating a hard dependency between your code features and the FedRAMP environment - see go-is-fedramp

Returns whether the service is deployed in the FedRAMP boundary. isFedRamp() relies on window.UNSAFE_ATL_CONTEXT_BOUNDARY be present on the page, in case window.UNSAFE_ATL_CONTEXT_BOUNDARY is undefined it will try to identify the environment based on the site domain, eventually fallback to false.

import { isFedRamp } from '@atlaskit/atlassian-context';

if (isFedRamp()) {
    // your specific logic here
}

isFedrampModerate()

Returns true if the current perimeter is in FedRAMP-Moderate.

isIsolatedCloud()

Returns true if the current perimeter is in Isolated Cloud.

isolatedCloudDomain()

Returns the current ic_domain. If the current perimeter is not an L2 IC (ex. the current fedramp-moderate or regular commercial), then undefined is returned.

isolationContextId()

Returns the current isolation context identifier (ex: ic-123). If the current perimeter is not an L2 IC (such as if the perimeter is fedramp-moderate or regular commercial), then undefined is returned.

getDomainInContext(subdomain, environment)

Returns the full domain (including support for Isolation Cloud) for a given Atlassian service or experience.

Important: Note that the library currently does NOT guarantee that the requested domain exists! It is assumed that when a user requests the full domain for a specific service, they already know the domain exists.

Parameters:

  • subdomain is a required parameter. This should be the service or Atlassian experience for which the full domain is being requested.

  • environment is a required parameter. This should be one of dev, staging, or prod.

Non-Isolated Cloud Details:

For Non-Isolated Cloud (ex. fedramp-moderate and regular commercial), the perimeter and environment values will be used to create and return the expected domain.

Exceptions to this are stored in the fullDomainOverride definitions. If you require a URL Mapping that is inconsistent between perimeters and environments, then you should add an entry to domains.tsx.

Examples: When called in fedramp-moderate:

import { getDomainInContext } from '@atlaskit/atlassian-context';

getDomainInContext('id', 'staging') // returns "id.stg.atlassian-us-gov-mod.com" (id has a full domain override)
getDomainInContext('analytics', 'staging') // returns "analytics.atlassian.com" because `analytics` is a non-varying global domain
getDomainInContext('nonexistent-service', 'staging') // returns "nonexistent-service.stg.atlassian-us-gov-mod.com"

When called in (non-isolated) commercial:

import { getDomainInContext } from '@atlaskit/atlassian-context';

getDomainInContext('id', 'prod') // returns "id.atlassian.com"
getDomainInContext('analytics', 'prod') // returns "analytics.atlassian.com"

Isolated Cloud Details:

For Oasis, one of three domain types are returned: a Reserved Name domain, a namespace subdomain, or an Atlassian services subdomain (see RFC).

Reserved names and the namespace subdomains are temporarily being configured in the ReservedNameMapping and AtlDomainMapping definitions. If a new name has been registered under one of these categories, please raise a PR to update the relevant mapping.

Precedence is as follows: reserved name pattern > namespace pattern > default to the services pattern.

Example: When called in (isolated) commercial:

import { getDomainInContext } from '@atlaskit/atlassian-context';

getDomainInContext('id') // returns "id.<icLabel>.<baseDomain>"
getDomainInContext('packages') // returns "packages.atl.<icLabel>.<baseDomain>"
getDomainInContext('new-service') // returns "new-service.services.<icLabel>.<baseDomain>"

getUrlForDomainInContext(subdomain, environment)

Returns the full url a given Atlassian service (including support for Isolation Cloud) by appending the current URL scheme to the result of getDomainInContext(subdomain, environment).

import { getUrlForDomainInContext } from '@atlaskit/atlassian-context';

getUrlForDomainInContext('design', 'staging') // --> returns "https://design.atlassian.com"

resolveProvidedUrlByBoundary(urls)

Given a user-provided map of boundary keys to URLs, returns the URL associated with the current boundary. Unlike getUrlForDomainInContext(subdomain, environment), which constructs a URL from a known Atlassian subdomain pattern, resolveProvidedUrlByBoundary is intended for cases where you have fully-formed, arbitrary URLs that may completely differ per boundary (for example, third-party service endpoints or custom backend URLs).

The only parameter is urls, a map of boundary keys to URL objects. The default key is required as a guaranteed fallback; all boundary-specific keys are optional. Valid keys are 'isolated-cloud' | 'fedramp-moderate' | 'commercial' | 'default' (required)

Resolution order:

  1. Specific boundary key ('isolated-cloud', 'fedramp-moderate', or 'commercial')

  2. 'default'

Pass null for a boundary key to explicitly return null for that boundary (i.e. opt out of returning a URL).

Note: URL values are constructed by the caller using new URL(...). Passing an invalid URL string to new URL() will throw a TypeError before resolveProvidedUrlByBoundary is invoked.

import { resolveProvidedUrlByBoundary } from '@atlaskit/atlassian-context/resolve-provided-url-by-boundary';

const url = resolveProvidedUrlByBoundary({
  'isolated-cloud':   new URL('https://ic.example.com'),  // returned in Isolated Cloud
  'fedramp-moderate': null,                                // explicitly no URL in FedRAMP to represent FedRAMP unavailability
  default:            new URL('https://example.com'),      // returned in all other boundaries
});

版本与发布记录

@atlaskit/atlassian-context 共发布 22 个版本,首次发布于 2024/06/12;过去 12 个月发布了 11 个版本。

版本发布日期距今
2.0.0latest2026/09/241 个月前
1.2.02026/09/151 个月前
1.1.12026/07/153 个月前
1.1.02026/07/143 个月前
1.0.02026/06/164 个月前
0.11.02026/06/124 个月前

关于 @atlaskit/atlassian-context 的常见问题

@atlaskit/atlassian-context 是什么?

Provides perimeter-specific URL resolution and helps identify which environment a product is running in.

如何安装 @atlaskit/atlassian-context?

在项目目录运行 npm install @atlaskit/atlassian-context,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atlaskit/atlassian-context 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atlaskit/atlassian-context 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@atlaskit/atlassian-context 可以商用吗?

@atlaskit/atlassian-context 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@atlaskit/atlassian-context 的下载量有多少?

根据 npm 官方下载统计,@atlaskit/atlassian-context 在 2026/10/07 – 2026/11/05 这 30 天内被下载 5,597,263 次,日均约 186,575 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atlaskit/atlassian-context 还在维护吗?

最新版本 2.0.0 发布于 2026/09/24(1 个月前);至今共发布 22 个版本,其中过去 12 个月发布了 11 个;首次发布于 2024/06/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。