@equinor/fusion-framework-react

中文文档
9.0.5发布于 2026/11/12ISCTypeScriptES Module近 30 天下载 7404
原始使用文档
文档目录19 节
  1. Features
  2. Installation
  3. Usage
  4. Bootstrap the framework (declarative)
  5. Bootstrap the framework (factory)
  6. Consume the framework
  7. Get a specific module
  8. API Reference
  9. Components
  10. Factory
  11. Core hooks
  12. App hooks ( /app )
  13. Context hook ( /context )
  14. Feature-flag hooks ( /feature-flag )
  15. HTTP hook ( /http )
  16. Convenience hooks ( /hooks )
  17. SignalR hook ( /signalr )
  18. Re-exported types
  19. Sub-entry-points

@equinor/fusion-framework-react

React bindings for bootstrapping and consuming a Fusion Framework instance inside a React application tree.

Features

  • Framework provider — initialise and distribute the framework via React context with a single component or factory function.
  • useFramework hook — access the active Fusion instance from any descendant component.
  • Module hooks — retrieve individual framework modules (useFrameworkModule) without manual wiring.
  • App hooks — observe the currently active application, query app manifests, and access app-level modules.
  • Context hook — read the currently selected Fusion context.
  • Feature-flag hooks — read, toggle, and observe feature flags at the framework or application level.
  • HTTP hook — obtain pre-configured HTTP clients (portal, people) from the framework.
  • Auth hook — retrieve the currently authenticated user.
  • SignalR hook — subscribe to real-time SignalR hub topics.

Installation

pnpm add @equinor/fusion-framework-react

Usage

Bootstrap the framework (declarative)

import { Framework } from '@equinor/fusion-framework-react';

const App = () => (
  <Framework
    configure={(configurator) => {
      configurator.http.configureClient('my-api', {
        baseUri: 'https://api.example.com',
      });
    }}
    fallback={<span>Loading…</span>}
  >
    <MyApp />
  </Framework>
);

Bootstrap the framework (factory)

import { createFrameworkProvider } from '@equinor/fusion-framework-react';
import { Suspense, useMemo } from 'react';

const Portal = () => {
  const Provider = useMemo(
    () =>
      createFrameworkProvider((config) => {
        config.http.configureClient('my-api', {
          baseUri: 'https://api.example.com',
        });
      }),
    [],
  );

  return (
    <Suspense fallback={<span>Loading…</span>}>
      <Provider>
        <App />
      </Provider>
    </Suspense>
  );
};

Consume the framework

import { useFramework } from '@equinor/fusion-framework-react';

const useMyService = () => {
  const fusion = useFramework();
  return fusion.modules.http.createClient('my-api');
};

Get a specific module

import { useFrameworkModule } from '@equinor/fusion-framework-react';
import type { HttpModule } from '@equinor/fusion-framework-module-http';

const http = useFrameworkModule<HttpModule>('http');

API Reference

Components

ExportDescription
FrameworkDeclarative component that initialises the framework and wraps children in providers.
FrameworkProviderLow-level React context provider for an existing Fusion instance.

Factory

ExportDescription
createFrameworkProvider(cb, ref?)Creates a React.lazy component that initialises the framework asynchronously. Must be rendered inside <Suspense>.

Core hooks

HookDescription
useFramework()Returns the active Fusion instance from context.
useFrameworkModule(name)Returns a specific module from the framework by key.

App hooks (/app)

HookDescription
useApps(args?)Lists available app manifests.
useCurrentApp()Observes and returns the currently active app.
useCurrentAppModule(key)Retrieves a module from the current app.
useCurrentAppModules()Observes initialised modules of the current app.
useAppProvider()Returns the raw AppModule provider.

Context hook (/context)

HookDescription
useCurrentContext()Returns the currently selected Fusion context.

Feature-flag hooks (/feature-flag)

HookDescription
useFeature(provider, key)Reads and toggles a single feature flag.
useFeatures(provider, selector?)Returns all feature flags with optional filtering.
useFrameworkFeature(key)Reads a feature flag from the framework provider.
useFrameworkFeatures()Returns all framework-level feature flags.
useCurrentAppFeatures()Returns feature flags for the current app.

HTTP hook (/http)

HookDescription
useFrameworkHttpClient(name)Returns a pre-configured HTTP client.

Convenience hooks (/hooks)

HookDescription
useHttpClient(name)Returns a framework HTTP client ('portal' or 'people').
useCurrentUser()Returns the authenticated user's account info.

SignalR hook (/signalr)

HookDescription
useSignalR(hubId, topicId)Subscribes to a SignalR hub topic.

Re-exported types

TypeSource
Fusion@equinor/fusion-framework
FusionConfigurator@equinor/fusion-framework
AppManifest, AppConfig, AppType, IApp@equinor/fusion-framework-module-app
IFeatureFlag, IFeatureFlagProvider@equinor/fusion-framework-module-feature-flag

Sub-entry-points

The package exposes several sub-entry-points for tree-shakeable imports:

  • @equinor/fusion-framework-react — core providers and hooks
  • @equinor/fusion-framework-react/app — application hooks
  • @equinor/fusion-framework-react/context — context hooks
  • @equinor/fusion-framework-react/feature-flag — feature-flag hooks
  • @equinor/fusion-framework-react/hooks — convenience hooks
  • @equinor/fusion-framework-react/http — HTTP hooks
  • @equinor/fusion-framework-react/signalr — SignalR hooks

版本与发布记录

@equinor/fusion-framework-react 共发布 340 个版本,首次发布于 2022/01/14;过去 12 个月发布了 18 个版本。

版本发布日期距今
9.0.5latest2026/11/121 天前
9.0.5-next.1next2026/11/112 天前
9.0.5-next.02026/10/2816 天前
9.0.42026/10/1727 天前
9.0.4-trusted-publishing-20261015-9dfe7602cd2a49a8a9df00d62c26e7304a82a85atrusted-publishing-202610152026/10/1629 天前
9.0.32026/10/121 个月前

其他发布通道:apploader → 7.4.13-apploader-be21a6b60eb13eee8bf869e75002d8634e9c50a9,cli-search-index → 7.4.20-cli-search-index.0,msal-v5 → 7.4.20-msal-v5.1,trusted-publishing-20261015 → 9.0.4-trusted-publishing-20261015-9dfe7602cd2a49a8a9df00d62c26e7304a82a85a,next → 9.0.5-next.1。

关于 @equinor/fusion-framework-react 的常见问题

如何安装 @equinor/fusion-framework-react?

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

@equinor/fusion-framework-react 支持 TypeScript 吗?

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

@equinor/fusion-framework-react 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@equinor/fusion-framework-react 可以商用吗?

@equinor/fusion-framework-react 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@equinor/fusion-framework-react 的下载量有多少?

根据 npm 官方下载统计,@equinor/fusion-framework-react 在 2026/10/14 – 2026/11/12 这 30 天内被下载 7,404 次,日均约 247 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@equinor/fusion-framework-react 还在维护吗?

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