@appshell/react-shell

中文文档
1.0.0-alpha.148发布于 2026/10/30MITCommonJS零依赖构建来源已验证近 30 天下载 5888

Appshell shell bundle for React

原始使用文档
文档目录4 节
  1. Choosing a bundle
  2. Working on the bundle
  3. Application configuration
  4. What fills the page before the root remote mounts

Appshell CI

@appshell/react-shell

Appshell React shell for building micro-frontends with Appshell and Webpack Module federation.

Working examples can be found here.

@appshell/react-shell is the browser bundle that mounts your micro-frontends. It is not a server — the Appshell registry renders the shell document, inlines the resolved composition, and serves this bundle at the URL an application's shellBundleUrl points at.

Building a micro-frontend? You do not need this package. Run your own dev server and publish to an application; the registry loads the shell bundle for you. This README is for pinning which bundle an application uses, and for working on the bundle itself.

Choosing a bundle

Every application resolves a shell bundle. By default that is the one the registry image ships, so there is nothing to configure. Point shellBundleUrl elsewhere to pin a version or serve from a CDN:

appshell app create my-env --shell-bundle-url https://cdn.example.com/appshell/1.2.3/main.js

The package publishes dist/ and nothing else, so a registry image can serve it under a versioned path and pinning becomes an ordinary dependency bump:

RUN npm install @appshell/[email protected]
RUN cp -R node_modules/@appshell/react-shell/dist public/shell

Working on the bundle

npm start serves main.js and nothing else — the registry still renders the shell, so you develop against the same path a deployment takes. The registry does not need to be local: shellBundleUrl is resolved by the browser, so a shared registry can point at your machine.

npm start
appshell app create shell-dev --ephemeral --shell-bundle-url http://localhost:3030/main.js

Note Chrome and Firefox treat localhost as a trustworthy origin, so an https registry may load an http bundle from it. Safari is stricter — run the registry locally, or serve main.js over TLS.

Application configuration

The registry supplies the root remote, its props, and the page's title, colours, favicon and stylesheet, inlining them into the document it serves. None of it comes from this package's environment any more.

What remains here is dev-server and CLI configuration:

# Port the bundle's development server listens on
APPSHELL_PORT=3030
# Registry to publish and activate against
APPSHELL_REGISTRY=
# Credential for that registry
APPSHELL_API_KEY=

What fills the page before the root remote mounts

Nothing, currently. The shell renders no fallback: what covers the gap while the root remote is fetched is the application's business, and it cannot come from the root package itself — that package is the thing being waited for. It has to come from the document the registry renders.

The shell used to ship a Splash component for this, configured through two env vars that stopped reaching the browser when the registry took over page rendering, so it had been rendering its hardcoded fallback colours for some time. It was removed rather than rewired: a document-level splash paints on the document's first paint rather than after the shell bundle downloads, parses and mounts React, and it can be styled by the application instead of by this package.

Inner remotes are unaffected — RemoteSlot takes a fallback prop, and that has always been the consumer's to supply.

版本与发布记录

@appshell/react-shell 共发布 138 个版本,首次发布于 2026/08/18;过去 12 个月发布了 138 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0-alpha.148latest2026/10/309 天前
1.0.0-alpha.1472026/10/2910 天前
1.0.0-alpha.1462026/10/2810 天前
1.0.0-alpha.1452026/10/2810 天前
1.0.0-alpha.1442026/10/2712 天前
1.0.0-alpha.1432026/10/2613 天前

关于 @appshell/react-shell 的常见问题

@appshell/react-shell 是什么?

Appshell shell bundle for React

如何安装 @appshell/react-shell?

在项目目录运行 npm install @appshell/react-shell,或使用 pnpm add / yarn add / bun add。

@appshell/react-shell 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/appshell__react-shell 是否存在。

@appshell/react-shell 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@appshell/react-shell 可以商用吗?

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

@appshell/react-shell 的下载量有多少?

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

@appshell/react-shell 还在维护吗?

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