@modern-js/main-doc 2.69.5 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/en/{_meta.json → _nav.json} +5 -1
- package/docs/en/apis/app/commands.mdx +2 -3
- package/docs/en/apis/app/hooks/src/entry.mdx +1 -5
- package/docs/en/apis/app/hooks/src/entry.server.mdx +4 -5
- package/docs/en/apis/app/hooks/src/routes.mdx +2 -2
- package/docs/en/apis/app/runtime/_meta.json +0 -18
- package/docs/en/apis/app/runtime/bff/use-hono-context.mdx +2 -2
- package/docs/en/apis/app/runtime/router/router.mdx +1 -1
- package/docs/en/apis/app/runtime/utility/css-in-js.mdx +3 -2
- package/docs/en/community/blog/v2-release-note.mdx +0 -2
- package/docs/en/community/contributing-guide.mdx +10 -12
- package/docs/en/components/bff-upload.mdx +16 -12
- package/docs/en/components/build-output.mdx +45 -0
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/enable-bff-caution.mdx +2 -2
- package/docs/en/components/enable-bff.mdx +38 -8
- package/docs/en/components/enable-ssg.mdx +48 -0
- package/docs/en/components/entry-scan-logic.mdx +7 -0
- package/docs/en/components/init-app.mdx +40 -17
- package/docs/en/components/international/install-command.mdx +9 -0
- package/docs/en/components/international/introduce.mdx +2 -0
- package/docs/en/components/module-federation.mdx +4 -4
- package/docs/en/components/new-entry-tooltip.mdx +0 -0
- package/docs/en/components/nodeVersion.mdx +2 -6
- package/docs/en/components/prerequisites.mdx +1 -1
- package/docs/en/components/ua-polyfill.mdx +16 -12
- package/docs/en/components/upgrade-browserslist.mdx +0 -0
- package/docs/en/configure/_meta.json +7 -8
- package/docs/en/configure/app/bff/cross-project.mdx +24 -0
- package/docs/en/configure/app/dev/lazy-compilation.mdx +45 -0
- package/docs/en/configure/app/dev/server.mdx +103 -0
- package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
- package/docs/en/configure/app/html/app-icon.mdx +1 -23
- package/docs/en/configure/app/output/inline-scripts.mdx +1 -1
- package/docs/en/configure/app/output/override-browserslist.mdx +6 -4
- package/docs/en/configure/app/output/source-map.mdx +6 -3
- package/docs/en/configure/app/output/ssg.mdx +12 -43
- package/docs/en/configure/app/output/ssgByEntries.mdx +93 -0
- package/docs/en/configure/app/performance/build-cache.mdx +0 -4
- package/docs/en/configure/app/resolve/alias-strategy.mdx +14 -0
- package/docs/en/configure/app/resolve/alias.mdx +13 -0
- package/docs/en/configure/app/resolve/condition-names.mdx +18 -0
- package/docs/en/configure/app/resolve/dedupe.mdx +13 -0
- package/docs/en/configure/app/resolve/extensions.mdx +18 -0
- package/docs/en/configure/app/runtime/0-intro.mdx +2 -51
- package/docs/en/configure/app/security/check-syntax.mdx +1 -1
- package/docs/en/configure/app/server/port.mdx +1 -21
- package/docs/en/configure/app/server/rsc.mdx +30 -0
- package/docs/en/configure/app/server/ssr.mdx +20 -9
- package/docs/en/configure/app/source/decorators.mdx +4 -2
- package/docs/en/configure/app/source/entries.mdx +0 -2
- package/docs/en/configure/app/source/main-entry-name.mdx +4 -4
- package/docs/en/configure/app/source/transform-import.mdx +1 -59
- package/docs/en/configure/app/tools/bundler-chain.mdx +5 -5
- package/docs/en/configure/app/tools/css-extract.mdx +1 -1
- package/docs/en/configure/app/tools/dev-server.mdx +14 -248
- package/docs/en/configure/app/tools/html-plugin.mdx +3 -3
- package/docs/en/configure/app/tools/lightningcss-loader.mdx +0 -1
- package/docs/en/configure/app/tools/swc.mdx +1 -43
- package/docs/en/configure/app/usage.mdx +7 -17
- package/docs/en/guides/_meta.json +1 -2
- package/docs/en/guides/advanced-features/_meta.json +6 -0
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +1 -7
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/docs/en/guides/advanced-features/bff/function.mdx +2 -6
- package/docs/en/guides/advanced-features/bff/sdk.mdx +3 -3
- package/docs/en/guides/advanced-features/build-performance.mdx +23 -26
- package/docs/en/guides/advanced-features/compatibility.mdx +53 -9
- package/docs/en/guides/advanced-features/international/_meta.json +11 -0
- package/docs/en/guides/advanced-features/international/advanced.mdx +193 -0
- package/docs/en/guides/advanced-features/international/api.mdx +400 -0
- package/docs/en/guides/advanced-features/international/basic.mdx +417 -0
- package/docs/en/guides/advanced-features/international/best-practices.mdx +135 -0
- package/docs/en/guides/advanced-features/international/configuration.mdx +437 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
- package/docs/en/guides/advanced-features/international/quick-start.mdx +154 -0
- package/docs/en/guides/advanced-features/international/resource-loading.mdx +417 -0
- package/docs/en/guides/advanced-features/international/routing.mdx +212 -0
- package/docs/en/guides/advanced-features/international.mdx +37 -0
- package/docs/en/guides/advanced-features/low-level.mdx +21 -16
- package/docs/en/guides/advanced-features/page-performance/code-split.mdx +4 -4
- package/docs/en/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
- package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +7 -21
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
- package/docs/en/guides/advanced-features/rspack-start.mdx +2 -22
- package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +62 -34
- package/docs/en/guides/advanced-features/web-server.mdx +82 -299
- package/docs/en/guides/basic-features/_meta.json +6 -1
- package/docs/en/guides/basic-features/css/css-in-js.mdx +46 -11
- package/docs/en/guides/basic-features/css/css-modules.mdx +5 -17
- package/docs/en/guides/basic-features/css/css.mdx +3 -3
- package/docs/en/guides/basic-features/css/tailwindcss.mdx +5 -89
- package/docs/en/guides/basic-features/data/data-cache.mdx +5 -1
- package/docs/en/guides/basic-features/data/data-fetch.mdx +4 -4
- package/docs/en/guides/basic-features/data/data-write.mdx +2 -2
- package/docs/en/guides/basic-features/debug/mock.mdx +4 -1
- package/docs/en/guides/basic-features/debug/proxy.mdx +0 -8
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +5 -5
- package/docs/en/guides/basic-features/deploy.mdx +25 -18
- package/docs/en/guides/basic-features/env-vars.mdx +1 -1
- package/docs/en/guides/basic-features/html.mdx +1 -1
- package/docs/en/guides/basic-features/output-files.mdx +3 -3
- package/docs/en/guides/basic-features/render/_meta.json +1 -1
- package/docs/en/guides/basic-features/render/before-render.mdx +16 -23
- package/docs/en/guides/basic-features/render/overview.mdx +51 -0
- package/docs/en/guides/basic-features/render/rsc.mdx +394 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +26 -62
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -6
- package/docs/en/guides/basic-features/render/ssr.mdx +31 -31
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +29 -9
- package/docs/en/guides/basic-features/routes/_meta.json +1 -0
- package/docs/en/guides/basic-features/routes/config-routes.mdx +427 -0
- package/docs/en/guides/basic-features/{routes.mdx → routes/routes.mdx} +7 -110
- package/docs/en/guides/basic-features/static-assets/json-files.mdx +21 -3
- package/docs/en/guides/basic-features/static-assets.mdx +2 -2
- package/docs/en/guides/concept/builder.mdx +24 -9
- package/docs/en/guides/concept/entries.mdx +139 -147
- package/docs/en/guides/get-started/glossary.mdx +0 -18
- package/docs/en/guides/get-started/introduction.mdx +1 -4
- package/docs/en/guides/get-started/quick-start.mdx +8 -73
- package/docs/en/guides/get-started/tech-stack.mdx +7 -25
- package/docs/en/guides/get-started/upgrade.mdx +30 -23
- package/docs/en/guides/topic-detail/_meta.json +0 -12
- package/docs/en/guides/topic-detail/module-federation/_meta.json +1 -1
- package/docs/en/guides/topic-detail/module-federation/application.mdx +16 -15
- package/docs/en/guides/topic-detail/module-federation/i18n.mdx +670 -0
- package/docs/en/guides/topic-detail/module-federation/introduce.mdx +5 -4
- package/docs/en/guides/topic-detail/module-federation/ssr.mdx +50 -2
- package/docs/en/guides/topic-detail/module-federation/usage.mdx +10 -30
- package/docs/en/guides/troubleshooting/builder.mdx +3 -82
- package/docs/en/guides/troubleshooting/cli.mdx +6 -30
- package/docs/en/guides/troubleshooting/dependencies.mdx +22 -22
- package/docs/en/plugin/cli-plugins/api.mdx +4 -5
- package/docs/en/plugin/cli-plugins/migration.mdx +33 -48
- package/docs/en/plugin/introduction.mdx +39 -27
- package/docs/en/plugin/official/_meta.json +0 -5
- package/docs/en/plugin/official/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/en/plugin/official/cli-plugins.mdx +0 -2
- package/docs/en/plugin/plugin-system.mdx +68 -61
- package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
- package/docs/en/plugin/runtime-plugins/migration.mdx +29 -20
- package/docs/en/tutorials/_meta.json +0 -10
- package/docs/en/tutorials/examples/csr-auth.mdx +1 -1
- package/docs/en/tutorials/foundations/introduction.mdx +9 -25
- package/docs/zh/{_meta.json → _nav.json} +10 -6
- package/docs/zh/apis/app/commands.mdx +2 -3
- package/docs/zh/apis/app/hooks/src/entry.mdx +1 -5
- package/docs/zh/apis/app/hooks/src/entry.server.mdx +4 -5
- package/docs/zh/apis/app/hooks/src/routes.mdx +2 -2
- package/docs/zh/apis/app/runtime/_meta.json +0 -18
- package/docs/zh/apis/app/runtime/bff/use-hono-context.mdx +2 -2
- package/docs/zh/apis/app/runtime/utility/css-in-js.mdx +3 -2
- package/docs/zh/community/blog/v2-release-note.mdx +0 -2
- package/docs/zh/community/contributing-guide.mdx +10 -12
- package/docs/zh/components/auto-upgrade.mdx +0 -0
- package/docs/zh/components/bff-upload.mdx +8 -5
- package/docs/zh/components/build-output.mdx +45 -0
- package/docs/zh/components/debug-app.mdx +1 -1
- package/docs/zh/components/enable-bff-caution.mdx +1 -1
- package/docs/zh/components/enable-bff.mdx +37 -8
- package/docs/zh/components/enable-ssg.mdx +47 -0
- package/docs/zh/components/entry-scan-logic.mdx +7 -0
- package/docs/zh/components/init-app.mdx +40 -18
- package/docs/zh/components/international/install-command.mdx +8 -0
- package/docs/zh/components/international/introduce.mdx +2 -0
- package/docs/zh/components/international/platform-support.mdx +0 -0
- package/docs/zh/components/module-federation.mdx +4 -4
- package/docs/zh/components/new-entry-tooltip.mdx +0 -0
- package/docs/zh/components/nodeVersion.mdx +3 -7
- package/docs/zh/components/prerequisites.mdx +1 -1
- package/docs/zh/components/self-route-example.mdx +3 -3
- package/docs/zh/components/ua-polyfill.mdx +11 -6
- package/docs/zh/components/upgrade-browserslist.mdx +0 -0
- package/docs/zh/configure/_meta.json +7 -8
- package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
- package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
- package/docs/zh/configure/app/dev/server.mdx +104 -0
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
- package/docs/zh/configure/app/html/app-icon.mdx +1 -23
- package/docs/zh/configure/app/output/inline-scripts.mdx +1 -1
- package/docs/zh/configure/app/output/override-browserslist.mdx +3 -3
- package/docs/zh/configure/app/output/source-map.mdx +10 -3
- package/docs/zh/configure/app/output/ssg.mdx +13 -45
- package/docs/zh/configure/app/output/ssgByEntries.mdx +94 -0
- package/docs/zh/configure/app/performance/build-cache.mdx +0 -4
- package/docs/zh/configure/app/resolve/alias-strategy.mdx +14 -0
- package/docs/zh/configure/app/resolve/alias.mdx +13 -0
- package/docs/zh/configure/app/resolve/condition-names.mdx +18 -0
- package/docs/zh/configure/app/resolve/dedupe.mdx +14 -0
- package/docs/zh/configure/app/resolve/extensions.mdx +18 -0
- package/docs/zh/configure/app/runtime/0-intro.mdx +2 -53
- package/docs/zh/configure/app/security/check-syntax.mdx +1 -1
- package/docs/zh/configure/app/server/port.mdx +2 -21
- package/docs/zh/configure/app/server/rsc.mdx +30 -0
- package/docs/zh/configure/app/server/ssr.mdx +21 -11
- package/docs/zh/configure/app/source/decorators.mdx +4 -4
- package/docs/zh/configure/app/source/entries.mdx +0 -2
- package/docs/zh/configure/app/source/main-entry-name.mdx +4 -4
- package/docs/zh/configure/app/source/transform-import.mdx +1 -59
- package/docs/zh/configure/app/tools/bundler-chain.mdx +6 -6
- package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
- package/docs/zh/configure/app/tools/dev-server.mdx +14 -248
- package/docs/zh/configure/app/tools/html-plugin.mdx +3 -2
- package/docs/zh/configure/app/tools/lightningcss-loader.mdx +0 -1
- package/docs/zh/configure/app/tools/swc.mdx +1 -43
- package/docs/zh/configure/app/usage.mdx +8 -18
- package/docs/zh/guides/_meta.json +5 -1
- package/docs/zh/guides/advanced-features/_meta.json +6 -1
- package/docs/zh/guides/advanced-features/bff/cross-project.mdx +8 -16
- package/docs/zh/guides/advanced-features/bff/extend-server.mdx +25 -8
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +4 -4
- package/docs/zh/guides/advanced-features/build-performance.mdx +23 -30
- package/docs/zh/guides/advanced-features/compatibility.mdx +44 -0
- package/docs/zh/guides/advanced-features/international/_meta.json +11 -0
- package/docs/zh/guides/advanced-features/international/advanced.mdx +193 -0
- package/docs/zh/guides/advanced-features/international/api.mdx +400 -0
- package/docs/zh/guides/advanced-features/international/basic.mdx +416 -0
- package/docs/zh/guides/advanced-features/international/best-practices.mdx +135 -0
- package/docs/zh/guides/advanced-features/international/configuration.mdx +441 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +149 -0
- package/docs/zh/guides/advanced-features/international/resource-loading.mdx +417 -0
- package/docs/zh/guides/advanced-features/international/routing.mdx +212 -0
- package/docs/zh/guides/advanced-features/international.mdx +36 -0
- package/docs/zh/guides/advanced-features/low-level.mdx +21 -16
- package/docs/zh/guides/advanced-features/page-performance/code-split.mdx +3 -3
- package/docs/zh/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
- package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +7 -21
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
- package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +63 -35
- package/docs/zh/guides/advanced-features/web-server.mdx +79 -300
- package/docs/zh/guides/basic-features/_meta.json +6 -1
- package/docs/zh/guides/basic-features/css/css-in-js.mdx +40 -5
- package/docs/zh/guides/basic-features/css/css-modules.mdx +6 -17
- package/docs/zh/guides/basic-features/css/css.mdx +2 -2
- package/docs/zh/guides/basic-features/css/tailwindcss.mdx +6 -90
- package/docs/zh/guides/basic-features/data/data-cache.mdx +8 -5
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +6 -5
- package/docs/zh/guides/basic-features/data/data-write.mdx +4 -4
- package/docs/zh/guides/basic-features/debug/mock.mdx +4 -1
- package/docs/zh/guides/basic-features/debug/proxy.mdx +0 -8
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +6 -6
- package/docs/zh/guides/basic-features/deploy.mdx +24 -20
- package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
- package/docs/zh/guides/basic-features/html.mdx +2 -2
- package/docs/zh/guides/basic-features/output-files.mdx +3 -3
- package/docs/zh/guides/basic-features/render/_meta.json +1 -1
- package/docs/zh/guides/basic-features/render/before-render.mdx +17 -24
- package/docs/zh/guides/basic-features/render/overview.mdx +52 -0
- package/docs/zh/guides/basic-features/render/rsc.mdx +413 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -5
- package/docs/zh/guides/basic-features/render/ssr.mdx +34 -31
- package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +34 -14
- package/docs/zh/guides/basic-features/routes/_meta.json +1 -0
- package/docs/zh/guides/basic-features/routes/config-routes.mdx +426 -0
- package/docs/zh/guides/basic-features/{routes.mdx → routes/routes.mdx} +8 -114
- package/docs/zh/guides/basic-features/static-assets/json-files.mdx +21 -3
- package/docs/zh/guides/basic-features/static-assets.mdx +2 -2
- package/docs/zh/guides/basic-features/testing/cypress.mdx +5 -5
- package/docs/zh/guides/basic-features/testing/jest.mdx +12 -12
- package/docs/zh/guides/concept/builder.mdx +24 -9
- package/docs/zh/guides/concept/entries.mdx +95 -92
- package/docs/zh/guides/get-started/glossary.mdx +0 -18
- package/docs/zh/guides/get-started/introduction.mdx +1 -5
- package/docs/zh/guides/get-started/quick-start.mdx +5 -72
- package/docs/zh/guides/get-started/tech-stack.mdx +8 -26
- package/docs/zh/guides/get-started/upgrade.mdx +30 -23
- package/docs/zh/guides/topic-detail/_meta.json +0 -12
- package/docs/zh/guides/topic-detail/module-federation/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/module-federation/application.mdx +18 -16
- package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +623 -0
- package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +4 -4
- package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +51 -5
- package/docs/zh/guides/topic-detail/module-federation/usage.mdx +11 -32
- package/docs/zh/guides/troubleshooting/builder.mdx +3 -84
- package/docs/zh/guides/troubleshooting/cli.mdx +6 -30
- package/docs/zh/guides/troubleshooting/dependencies.mdx +23 -23
- package/docs/zh/guides/upgrade/_meta.json +1 -0
- package/docs/zh/guides/upgrade/config.mdx +809 -0
- package/docs/zh/guides/upgrade/entry.mdx +463 -0
- package/docs/zh/guides/upgrade/other.md +90 -0
- package/docs/zh/guides/upgrade/overview.mdx +36 -0
- package/docs/zh/guides/upgrade/tailwindcss.mdx +130 -0
- package/docs/zh/guides/upgrade/web-server.md +93 -0
- package/docs/zh/plugin/cli-plugins/api.mdx +4 -5
- package/docs/zh/plugin/cli-plugins/migration.mdx +30 -45
- package/docs/zh/plugin/introduction.mdx +36 -24
- package/docs/zh/plugin/official/_meta.json +0 -5
- package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/zh/plugin/official/cli-plugins.mdx +0 -2
- package/docs/zh/plugin/plugin-system.mdx +45 -42
- package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
- package/docs/zh/plugin/runtime-plugins/migration.mdx +26 -17
- package/docs/zh/tutorials/_meta.json +0 -10
- package/docs/zh/tutorials/examples/csr-auth.mdx +1 -1
- package/docs/zh/tutorials/foundations/introduction.mdx +8 -25
- package/i18n.json +0 -16
- package/package.json +12 -12
- package/rspress.config.ts +5 -8
- package/src/components/ContentCard/index.module.scss +11 -7
- package/src/components/ContentCard/index.tsx +1 -1
- package/src/components/FeatureLayout/index.module.css +1 -1
- package/src/components/Footer/index.tsx +2 -14
- package/src/components/Footer/styles.module.scss +5 -5
- package/src/components/ListCard/index.tsx +1 -1
- package/src/components/RandomMemberList/index.tsx +1 -1
- package/src/components/RsbuildLink/index.tsx +1 -1
- package/src/components/Sandpack/index.tsx +1 -1
- package/src/custom.scss +15 -0
- package/src/i18n/enUS.ts +2 -4
- package/src/i18n/index.ts +1 -1
- package/src/i18n/zhCN.ts +2 -4
- package/src/index.ts +2 -1
- package/src/pages/index.module.scss +59 -41
- package/src/pages/index.tsx +9 -24
- package/docs/en/apis/app/hooks/server/index_.mdx +0 -10
- package/docs/en/apis/app/hooks/src/index_.mdx +0 -38
- package/docs/en/apis/app/hooks/src/stories.mdx +0 -16
- package/docs/en/apis/app/runtime/app/define-config.mdx +0 -67
- package/docs/en/apis/app/runtime/core/bootstrap.mdx +0 -74
- package/docs/en/apis/app/runtime/core/create-app.mdx +0 -49
- package/docs/en/apis/app/runtime/core/use-loader.mdx +0 -89
- package/docs/en/apis/app/runtime/core/use-module-apps.mdx +0 -140
- package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +0 -116
- package/docs/en/apis/app/runtime/model/Provider.mdx +0 -36
- package/docs/en/apis/app/runtime/model/auto-actions.mdx +0 -122
- package/docs/en/apis/app/runtime/model/connect.mdx +0 -146
- package/docs/en/apis/app/runtime/model/create-app.mdx +0 -75
- package/docs/en/apis/app/runtime/model/create-store.mdx +0 -61
- package/docs/en/apis/app/runtime/model/handle-effect.mdx +0 -107
- package/docs/en/apis/app/runtime/model/model_.mdx +0 -198
- package/docs/en/apis/app/runtime/model/use-local-model.mdx +0 -29
- package/docs/en/apis/app/runtime/model/use-model.mdx +0 -89
- package/docs/en/apis/app/runtime/model/use-static-model.mdx +0 -51
- package/docs/en/apis/app/runtime/model/use-store.mdx +0 -26
- package/docs/en/apis/app/runtime/ssr/pre-render.mdx +0 -96
- package/docs/en/apis/app/runtime/web-server/hook.mdx +0 -134
- package/docs/en/apis/app/runtime/web-server/middleware.mdx +0 -113
- package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +0 -167
- package/docs/en/components/bff-proxy-path-rewrite.mdx +0 -16
- package/docs/en/components/bff-proxy-principle.mdx +0 -1
- package/docs/en/components/builder.mdx +0 -3
- package/docs/en/components/create-bff-api-app.mdx +0 -25
- package/docs/en/components/custom-router-micro-frontend.mdx +0 -40
- package/docs/en/components/enable-micro-frontend.mdx +0 -30
- package/docs/en/components/enableSwc.mdx +0 -17
- package/docs/en/components/global-proxy-config.mdx +0 -85
- package/docs/en/components/global-proxy.mdx +0 -29
- package/docs/en/components/package-manager.mdx +0 -11
- package/docs/en/components/reduck-notify.mdx +0 -27
- package/docs/en/components/reduck-tip.mdx +0 -8
- package/docs/en/configure/app/auto-load-plugin.mdx +0 -66
- package/docs/en/configure/app/deploy/microFrontend.mdx +0 -53
- package/docs/en/configure/app/dev/port.mdx +0 -25
- package/docs/en/configure/app/dev/proxy.mdx +0 -9
- package/docs/en/configure/app/experiments/lazy-compilation.mdx +0 -106
- package/docs/en/configure/app/html/disable-html-folder.mdx +0 -46
- package/docs/en/configure/app/html/favicon-by-entries.mdx +0 -36
- package/docs/en/configure/app/html/inject-by-entries.mdx +0 -36
- package/docs/en/configure/app/html/meta-by-entries.mdx +0 -48
- package/docs/en/configure/app/html/tags-by-entries.mdx +0 -44
- package/docs/en/configure/app/html/template-by-entries.mdx +0 -33
- package/docs/en/configure/app/html/template-parameters-by-entries.mdx +0 -35
- package/docs/en/configure/app/html/title-by-entries.mdx +0 -37
- package/docs/en/configure/app/output/css-module-local-ident-name.mdx +0 -21
- package/docs/en/configure/app/output/disable-css-extract.mdx +0 -16
- package/docs/en/configure/app/output/disable-filename-hash.mdx +0 -16
- package/docs/en/configure/app/output/disable-minimize.mdx +0 -14
- package/docs/en/configure/app/output/disable-node-polyfill.mdx +0 -22
- package/docs/en/configure/app/output/disable-source-map.mdx +0 -31
- package/docs/en/configure/app/output/enable-asset-fallback.mdx +0 -36
- package/docs/en/configure/app/output/enable-inline-scripts.mdx +0 -22
- package/docs/en/configure/app/output/enable-inline-styles.mdx +0 -22
- package/docs/en/configure/app/output/enable-latest-decorators.mdx +0 -14
- package/docs/en/configure/app/performance/transform-lodash.mdx +0 -52
- package/docs/en/configure/app/runtime/master-app.mdx +0 -36
- package/docs/en/configure/app/runtime/state.mdx +0 -52
- package/docs/en/configure/app/source/disable-entry-dirs.mdx +0 -38
- package/docs/en/configure/app/source/enable-custom-entry.mdx +0 -68
- package/docs/en/configure/app/source/module-scopes.mdx +0 -72
- package/docs/en/configure/app/source/resolve-extension-prefix.mdx +0 -55
- package/docs/en/configure/app/source/resolve-main-fields.mdx +0 -46
- package/docs/en/configure/app/tools/esbuild.mdx +0 -44
- package/docs/en/configure/app/tools/pug.mdx +0 -54
- package/docs/en/configure/app/tools/styled-components.mdx +0 -55
- package/docs/en/configure/app/tools/tailwindcss.mdx +0 -98
- package/docs/en/configure/app/tools/terser.mdx +0 -58
- package/docs/en/configure/app/tools/ts-loader.mdx +0 -76
- package/docs/en/configure/app/tools/webpack-chain.mdx +0 -249
- package/docs/en/configure/app/tools/webpack.mdx +0 -305
- package/docs/en/guides/deprecated.md +0 -17
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -27
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +0 -290
- package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -298
- package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
- package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -26
- package/docs/en/guides/topic-detail/model/_meta.json +0 -14
- package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -85
- package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -148
- package/docs/en/guides/topic-detail/model/define-model.mdx +0 -62
- package/docs/en/guides/topic-detail/model/faq.mdx +0 -35
- package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -247
- package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -217
- package/docs/en/guides/topic-detail/model/performance.mdx +0 -167
- package/docs/en/guides/topic-detail/model/quick-start.mdx +0 -117
- package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -20
- package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -68
- package/docs/en/guides/topic-detail/model/use-model.mdx +0 -243
- package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
- package/docs/en/plugin/official/cli-plugins/plugin-swc.mdx +0 -363
- package/docs/en/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
- package/docs/en/plugin/official/rsbuild-plugins/_meta.json +0 -1
- package/docs/en/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -205
- package/docs/en/plugin/official/rsbuild-plugins.mdx +0 -3
- package/docs/en/tutorials/first-app/c01-start.mdx +0 -99
- package/docs/en/tutorials/first-app/c02-component.mdx +0 -60
- package/docs/en/tutorials/first-app/c03-css.mdx +0 -324
- package/docs/en/tutorials/first-app/c04-routes.mdx +0 -172
- package/docs/en/tutorials/first-app/c05-loader.mdx +0 -87
- package/docs/en/tutorials/first-app/c06-model.mdx +0 -278
- package/docs/en/tutorials/first-app/c07-container.mdx +0 -281
- package/docs/en/tutorials/first-app/c08-entries.mdx +0 -135
- package/docs/zh/apis/app/hooks/server/index_.mdx +0 -10
- package/docs/zh/apis/app/hooks/src/index_.mdx +0 -39
- package/docs/zh/apis/app/hooks/src/stories.mdx +0 -16
- package/docs/zh/apis/app/runtime/app/define-config.mdx +0 -67
- package/docs/zh/apis/app/runtime/core/bootstrap.mdx +0 -74
- package/docs/zh/apis/app/runtime/core/create-app.mdx +0 -35
- package/docs/zh/apis/app/runtime/core/use-loader.mdx +0 -89
- package/docs/zh/apis/app/runtime/core/use-module-apps.mdx +0 -179
- package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +0 -116
- package/docs/zh/apis/app/runtime/model/Provider.mdx +0 -36
- package/docs/zh/apis/app/runtime/model/auto-actions.mdx +0 -122
- package/docs/zh/apis/app/runtime/model/connect.mdx +0 -143
- package/docs/zh/apis/app/runtime/model/create-app.mdx +0 -75
- package/docs/zh/apis/app/runtime/model/create-store.mdx +0 -61
- package/docs/zh/apis/app/runtime/model/handle-effect.mdx +0 -108
- package/docs/zh/apis/app/runtime/model/model_.mdx +0 -201
- package/docs/zh/apis/app/runtime/model/use-local-model.mdx +0 -29
- package/docs/zh/apis/app/runtime/model/use-model.mdx +0 -89
- package/docs/zh/apis/app/runtime/model/use-static-model.mdx +0 -49
- package/docs/zh/apis/app/runtime/model/use-store.mdx +0 -26
- package/docs/zh/apis/app/runtime/ssr/pre-render.mdx +0 -96
- package/docs/zh/apis/app/runtime/web-server/hook.mdx +0 -136
- package/docs/zh/apis/app/runtime/web-server/middleware.mdx +0 -114
- package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +0 -165
- package/docs/zh/components/bff-proxy-path-rewrite.mdx +0 -16
- package/docs/zh/components/bff-proxy-principle.mdx +0 -1
- package/docs/zh/components/builder.mdx +0 -3
- package/docs/zh/components/create-bff-api-app.mdx +0 -25
- package/docs/zh/components/custom-router-micro-frontend.mdx +0 -40
- package/docs/zh/components/enable-micro-frontend.mdx +0 -30
- package/docs/zh/components/enableSwc.mdx +0 -17
- package/docs/zh/components/global-proxy-config.mdx +0 -85
- package/docs/zh/components/global-proxy.mdx +0 -29
- package/docs/zh/components/package-manager.mdx +0 -11
- package/docs/zh/components/reduck-notify.mdx +0 -27
- package/docs/zh/components/reduck-tip.mdx +0 -8
- package/docs/zh/configure/app/auto-load-plugin.mdx +0 -66
- package/docs/zh/configure/app/deploy/microFrontend.mdx +0 -55
- package/docs/zh/configure/app/dev/port.mdx +0 -25
- package/docs/zh/configure/app/dev/proxy.mdx +0 -9
- package/docs/zh/configure/app/experiments/lazy-compilation.mdx +0 -105
- package/docs/zh/configure/app/html/disable-html-folder.mdx +0 -45
- package/docs/zh/configure/app/html/favicon-by-entries.mdx +0 -37
- package/docs/zh/configure/app/html/inject-by-entries.mdx +0 -37
- package/docs/zh/configure/app/html/meta-by-entries.mdx +0 -48
- package/docs/zh/configure/app/html/tags-by-entries.mdx +0 -44
- package/docs/zh/configure/app/html/template-by-entries.mdx +0 -33
- package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +0 -36
- package/docs/zh/configure/app/html/title-by-entries.mdx +0 -37
- package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +0 -21
- package/docs/zh/configure/app/output/disable-css-extract.mdx +0 -16
- package/docs/zh/configure/app/output/disable-filename-hash.mdx +0 -16
- package/docs/zh/configure/app/output/disable-minimize.mdx +0 -14
- package/docs/zh/configure/app/output/disable-node-polyfill.mdx +0 -22
- package/docs/zh/configure/app/output/disable-source-map.mdx +0 -31
- package/docs/zh/configure/app/output/enable-asset-fallback.mdx +0 -36
- package/docs/zh/configure/app/output/enable-inline-scripts.mdx +0 -22
- package/docs/zh/configure/app/output/enable-inline-styles.mdx +0 -22
- package/docs/zh/configure/app/output/enable-latest-decorators.mdx +0 -14
- package/docs/zh/configure/app/performance/transform-lodash.mdx +0 -52
- package/docs/zh/configure/app/runtime/master-app.mdx +0 -38
- package/docs/zh/configure/app/runtime/state.mdx +0 -52
- package/docs/zh/configure/app/source/disable-entry-dirs.mdx +0 -38
- package/docs/zh/configure/app/source/enable-custom-entry.mdx +0 -67
- package/docs/zh/configure/app/source/module-scopes.mdx +0 -72
- package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +0 -57
- package/docs/zh/configure/app/source/resolve-main-fields.mdx +0 -46
- package/docs/zh/configure/app/tools/esbuild.mdx +0 -44
- package/docs/zh/configure/app/tools/pug.mdx +0 -54
- package/docs/zh/configure/app/tools/styled-components.mdx +0 -54
- package/docs/zh/configure/app/tools/tailwindcss.mdx +0 -98
- package/docs/zh/configure/app/tools/terser.mdx +0 -58
- package/docs/zh/configure/app/tools/ts-loader.mdx +0 -76
- package/docs/zh/configure/app/tools/webpack-chain.mdx +0 -253
- package/docs/zh/configure/app/tools/webpack.mdx +0 -305
- package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -154
- package/docs/zh/guides/deprecated.md +0 -19
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -26
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +0 -332
- package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -296
- package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
- package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -27
- package/docs/zh/guides/topic-detail/model/_meta.json +0 -14
- package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -88
- package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -147
- package/docs/zh/guides/topic-detail/model/define-model.mdx +0 -63
- package/docs/zh/guides/topic-detail/model/faq.mdx +0 -36
- package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -256
- package/docs/zh/guides/topic-detail/model/model-communicate.mdx +0 -217
- package/docs/zh/guides/topic-detail/model/performance.mdx +0 -167
- package/docs/zh/guides/topic-detail/model/quick-start.mdx +0 -117
- package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -20
- package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -67
- package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -248
- package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
- package/docs/zh/plugin/official/cli-plugins/plugin-swc.mdx +0 -351
- package/docs/zh/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
- package/docs/zh/plugin/official/rsbuild-plugins/_meta.json +0 -1
- package/docs/zh/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -201
- package/docs/zh/plugin/official/rsbuild-plugins.mdx +0 -3
- package/docs/zh/tutorials/first-app/c01-start.mdx +0 -99
- package/docs/zh/tutorials/first-app/c02-component.mdx +0 -60
- package/docs/zh/tutorials/first-app/c03-css.mdx +0 -323
- package/docs/zh/tutorials/first-app/c04-routes.mdx +0 -172
- package/docs/zh/tutorials/first-app/c05-loader.mdx +0 -89
- package/docs/zh/tutorials/first-app/c06-model.mdx +0 -274
- package/docs/zh/tutorials/first-app/c07-container.mdx +0 -281
- package/docs/zh/tutorials/first-app/c08-entries.mdx +0 -135
- /package/docs/en/components/{reduck-migration.mdx → auto-upgrade.mdx} +0 -0
- /package/docs/{zh/components/reduck-migration.mdx → en/components/international/platform-support.mdx} +0 -0
|
@@ -2,86 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[Tailwind CSS](https://tailwindcss.com/) is a CSS framework and design system based on Utility Class, which can quickly add common styles to components, and support flexible extension of theme styles.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Using Tailwind CSS in Modern.js
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
To use [Tailwind CSS](https://tailwindcss.com/) in Modern.js, you only need to configure it according to the Rsbuild steps. Rsbuild supports Tailwind CSS versions v3 and v4:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
? Please select the feature name: Enable Tailwind CSS
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
After successful initialization, you will see that the `package.json` has added dependencies for `tailwindcss` and `@modern-js/plugin-tailwindcss`.
|
|
15
|
-
|
|
16
|
-
2. Register the Tailwind plugin in `modern.config.ts`:
|
|
17
|
-
|
|
18
|
-
```ts title="modern.config.ts"
|
|
19
|
-
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
|
|
20
|
-
|
|
21
|
-
export default defineConfig({
|
|
22
|
-
plugins: [..., tailwindcssPlugin()],
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
3. Create a `index.css` file and add the following code:
|
|
27
|
-
|
|
28
|
-
```css title="index.css"
|
|
29
|
-
@tailwind base;
|
|
30
|
-
@tailwind components;
|
|
31
|
-
@tailwind utilities;
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
:::info
|
|
35
|
-
Depending on your needs, you can selectively import the CSS styles provided by Tailwind CSS. Please refer to the [`@tailwind` documentation](https://tailwindcss.com/docs/functions-and-directives#tailwind) for detailed usage of the `@tailwind` directive.
|
|
36
|
-
:::
|
|
37
|
-
|
|
38
|
-
4. Import the `index.css` file, for example, add the following code in the root component `src/App.jsx`:
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
import './index.css';
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
5. Now you can use the Utility Classes provided by Tailwind CSS in your components:
|
|
45
|
-
|
|
46
|
-
```tsx
|
|
47
|
-
const Hello = () => (
|
|
48
|
-
<div className="h-12 w-48">
|
|
49
|
-
<p className="text-xl font-medium text-black">hello world</p>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Configuring Tailwind CSS
|
|
55
|
-
|
|
56
|
-
In Modern.js, you have two ways to configure Tailwind CSS:
|
|
57
|
-
|
|
58
|
-
1. Using the `tailwind.config.{ts,js}` file, which follows the official usage of Tailwind CSS. Please refer to ["Tailwind CSS - Configuration"](https://tailwindcss.com/docs/configuration) for more details.
|
|
59
|
-
|
|
60
|
-
```ts title="tailwind.config.ts"
|
|
61
|
-
import type { Config } from 'tailwindcss';
|
|
62
|
-
|
|
63
|
-
export default {
|
|
64
|
-
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
|
65
|
-
} as Config;
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
:::tip
|
|
69
|
-
Please upgrade Modern.js to version >= MAJOR_VERSION.33.0 to support automatic reading of `tailwind.config.{ts,js}` files.
|
|
70
|
-
:::
|
|
71
|
-
|
|
72
|
-
2. Using the [tools.tailwindcss](/configure/app/tools/tailwindcss.html) configuration option. This is the old way of configuring Tailwind CSS, and we recommend using the `tailwind.config.{ts,js}` file for configuration.
|
|
73
|
-
|
|
74
|
-
```ts title="modern.config.ts"
|
|
75
|
-
export default {
|
|
76
|
-
tools: {
|
|
77
|
-
tailwindcss: {
|
|
78
|
-
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
If you are using both the `tailwind.config.{ts,js}` file and `tools.tailwindcss` option, the configuration defined in `tools.tailwindcss` will take precedence and override the content defined in `tailwind.config.{ts,js}`.
|
|
9
|
+
- [Tailwind CSS v3](https://rsbuild.rs/guide/styling/tailwindcss-v3#tailwind-css-v3)
|
|
10
|
+
- [Tailwind CSS v4](https://rsbuild.rs/guide/styling/tailwindcss)
|
|
85
11
|
|
|
86
12
|
## Tailwind CSS Autocomplete
|
|
87
13
|
|
|
@@ -92,20 +18,10 @@ You can follow the steps below to enable the autocomplete feature:
|
|
|
92
18
|
1. Install the [Tailwind CSS IntelliSense](https://github.com/tailwindlabs/tailwindcss-intellisense) extension in VS Code.
|
|
93
19
|
2. If the root directory of your project does not have a `tailwind.config.{ts,js}` file, you need to create one and write the Tailwind CSS configuration for your current project. Otherwise, the IDE plugin will not work correctly.
|
|
94
20
|
|
|
95
|
-
## Tailwind CSS Version
|
|
96
|
-
|
|
97
|
-
Modern.js supports both Tailwind CSS v2 and v3 versions, and the framework will recognize the version of the `tailwindcss` dependency in the project `package.json` file and enable the corresponding configuration. By default, we will install Tailwind CSS v3 version for you.
|
|
98
|
-
|
|
99
|
-
If your project is still using Tailwind CSS v2, we recommend that you upgrade to v3 to support JIT and other capabilities. For the differences between Tailwind CSS v2 and v3 versions, please refer to the following articles:
|
|
100
|
-
|
|
101
|
-
- [Tailwind CSS v3.0](https://tailwindcss.com/blog/tailwindcss-v3)
|
|
102
|
-
- [Upgrade Guide](https://tailwindcss.com/docs/upgrade-guide)
|
|
103
|
-
|
|
104
21
|
## Browser Compatibility
|
|
105
22
|
|
|
106
|
-
Tailwind CSS
|
|
23
|
+
Tailwind CSS v3 does not support the IE 11 browser, please refer to:
|
|
107
24
|
|
|
108
25
|
- [Tailwind CSS v3 - Browser Support](https://tailwindcss.com/docs/browser-support).
|
|
109
|
-
- [Tailwind CSS v2 - Browser Support](https://v2.tailwindcss.com/docs/browser-support)
|
|
110
26
|
|
|
111
27
|
If you use Tailwind CSS on IE 11 browser, some styles may not be available, please use it with caution.
|
|
@@ -123,7 +123,11 @@ const getDashboardStats = cache(
|
|
|
123
123
|
|
|
124
124
|
The `revalidate` parameter sets a time window for revalidating the cache after it expires. It can be used together with the `maxAge` parameter, similar to HTTP Cache-Control's stale-while-revalidate mode.
|
|
125
125
|
|
|
126
|
-
In the following example,
|
|
126
|
+
In the following example, the cache behavior is divided into three phases based on time:
|
|
127
|
+
|
|
128
|
+
1. **0 to 2 minutes (within `maxAge`)**: Cache is fresh, returns cached data directly without re-fetching
|
|
129
|
+
2. **2 to 3 minutes (between `maxAge` and `maxAge + revalidate`)**: Cache has expired but is within the revalidation window, returns stale data immediately while re-fetching and updating the cache in the background
|
|
130
|
+
3. **Beyond 3 minutes (exceeding `maxAge + revalidate`)**: Cache is completely expired, re-executes the function to fetch new data
|
|
127
131
|
|
|
128
132
|
```ts
|
|
129
133
|
import { cache, CacheTime } from '@modern-js/runtime/cache';
|
|
@@ -12,7 +12,7 @@ Modern.js provides out-of-the-box data fetching capabilities. Developers can use
|
|
|
12
12
|
In Modern.js v1 projects, data was fetched using `useLoader`. This is no longer the recommended approach; we suggest migrating to Data Loader.
|
|
13
13
|
:::
|
|
14
14
|
|
|
15
|
-
Modern.js recommends managing routes using [conventional routing](/guides/basic-features/routes). Each route component (`layout.ts`, `page.ts`, or `$.tsx`) can have a same-named `.data` file. These files can export a `loader` function, known as Data Loader, which executes before the corresponding route component renders to provide data for the component. Here is an example:
|
|
15
|
+
Modern.js recommends managing routes using [conventional routing](/guides/basic-features/routes/routes). Each route component (`layout.ts`, `page.ts`, or `$.tsx`) can have a same-named `.data` file. These files can export a `loader` function, known as Data Loader, which executes before the corresponding route component renders to provide data for the component. Here is an example:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
.
|
|
@@ -74,7 +74,7 @@ In an SSR environment, the `loader` function only executes on the server side fo
|
|
|
74
74
|
In future versions, Modern.js may support running `loader` functions on the server side even in CSR environments to improve performance and security. Therefore, it is advisable to keep the `loader` function pure, handling only data fetching scenarios.
|
|
75
75
|
:::
|
|
76
76
|
|
|
77
|
-
When navigating on the client side, based on [conventional routing](/guides/basic-features/routes), Modern.js supports parallel execution (requests) of all `loader` functions. For example, when visiting `/user/profile`, the `loader` functions under `/user` and `/user/profile` will execute in parallel, solving the request-render waterfall issue and significantly improving page performance.
|
|
77
|
+
When navigating on the client side, based on [conventional routing](/guides/basic-features/routes/routes), Modern.js supports parallel execution (requests) of all `loader` functions. For example, when visiting `/user/profile`, the `loader` functions under `/user` and `/user/profile` will execute in parallel, solving the request-render waterfall issue and significantly improving page performance.
|
|
78
78
|
|
|
79
79
|
## `loader` Function
|
|
80
80
|
|
|
@@ -82,7 +82,7 @@ The `loader` function has two parameters used for getting route parameters and r
|
|
|
82
82
|
|
|
83
83
|
### params
|
|
84
84
|
|
|
85
|
-
`params` is the dynamic route segments when the route is a [dynamic route](/guides/basic-features/routes#dynamic-routes), which passed as parameters to the `loader` function:
|
|
85
|
+
`params` is the dynamic route segments when the route is a [dynamic route](/guides/basic-features/routes/routes#dynamic-routes), which passed as parameters to the `loader` function:
|
|
86
86
|
|
|
87
87
|
```tsx title="routes/user/[id]/page.data.ts"
|
|
88
88
|
import { LoaderFunctionArgs } from '@modern-js/runtime/router';
|
|
@@ -167,7 +167,7 @@ export async function loader() {
|
|
|
167
167
|
|
|
168
168
|
### Basic Usage
|
|
169
169
|
|
|
170
|
-
In a `loader` function, you can handle errors by using `throw error` or `throw response`. When an error is thrown in the `loader` function, Modern.js will stop executing the remaining code in the current `loader` and switch the front-end UI to the defined [`ErrorBoundary`](/guides/basic-features/routes#error-handling) component:
|
|
170
|
+
In a `loader` function, you can handle errors by using `throw error` or `throw response`. When an error is thrown in the `loader` function, Modern.js will stop executing the remaining code in the current `loader` and switch the front-end UI to the defined [`ErrorBoundary`](/guides/basic-features/routes/routes#error-handling) component:
|
|
171
171
|
|
|
172
172
|
```tsx
|
|
173
173
|
// routes/user/profile/page.data.ts
|
|
@@ -13,7 +13,7 @@ In Modern.js, you can use Data Action to address these scenarios.
|
|
|
13
13
|
|
|
14
14
|
## What is Data Action
|
|
15
15
|
|
|
16
|
-
Modern.js recommends managing routes using [conventional routing](/guides/basic-features/routes). Each route component (`layout.ts`, `page.ts`, or `$.tsx`) can have a same-named `.data` file. These files can export an `action` function, known as Data Action, which developers can call at an appropriate time:
|
|
16
|
+
Modern.js recommends managing routes using [conventional routing](/guides/basic-features/routes/routes). Each route component (`layout.ts`, `page.ts`, or `$.tsx`) can have a same-named `.data` file. These files can export an `action` function, known as Data Action, which developers can call at an appropriate time:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
.
|
|
@@ -81,7 +81,7 @@ Similar to the `loader` function, the `action` function takes two parameters: `p
|
|
|
81
81
|
|
|
82
82
|
### params
|
|
83
83
|
|
|
84
|
-
`params` is the dynamic route segments when the route is a [dynamic route](/guides/basic-features/routes#dynamic-routes), which are passed as parameters to the `action` function:
|
|
84
|
+
`params` is the dynamic route segments when the route is a [dynamic route](/guides/basic-features/routes/routes#dynamic-routes), which are passed as parameters to the `action` function:
|
|
85
85
|
|
|
86
86
|
```tsx title="routes/user/[id]/page.data.ts"
|
|
87
87
|
import { ActionFunctionArgs } from '@modern-js/runtime/router;
|
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
72
|
export default {
|
|
73
|
-
'api/getInfo': (req, res) => {
|
|
73
|
+
'/api/getInfo': (req, res) => {
|
|
74
74
|
setTimeout(() => {
|
|
75
75
|
res.end('delay 2000ms');
|
|
76
76
|
}, 2000);
|
|
@@ -83,6 +83,9 @@ export default {
|
|
|
83
83
|
Under the `config/mock/index.ts`, you can also export the `config` to control the Mock service.
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
+
import type { IncomingMessage } from 'node:http';
|
|
87
|
+
import type { ServerResponse } from 'node:http';
|
|
88
|
+
|
|
86
89
|
type MockConfig = {
|
|
87
90
|
enable: ((req: IncomingMessage, res: ServerResponse) => boolean) | boolean;
|
|
88
91
|
};
|
|
@@ -4,8 +4,6 @@ sidebar_position: 6
|
|
|
4
4
|
|
|
5
5
|
# Network Proxy
|
|
6
6
|
|
|
7
|
-
## Local Proxy
|
|
8
|
-
|
|
9
7
|
Modern.js provides a way to configure the development proxy in [`tools.devServer`](/configure/app/tools/dev-server). For example, to proxy the local interface to an online address:
|
|
10
8
|
|
|
11
9
|
```ts title="modern.config.ts"
|
|
@@ -30,9 +28,3 @@ When access `http://localhost:8080/go/api`, the response content will be returne
|
|
|
30
28
|
:::info
|
|
31
29
|
For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).
|
|
32
30
|
:::
|
|
33
|
-
|
|
34
|
-
## Global Proxy
|
|
35
|
-
|
|
36
|
-
import GlobalProxy from "@site-docs-en/components/global-proxy"
|
|
37
|
-
|
|
38
|
-
<GlobalProxy />
|
|
@@ -26,14 +26,14 @@ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
|
26
26
|
export default {
|
|
27
27
|
// ...
|
|
28
28
|
tools: {
|
|
29
|
-
|
|
29
|
+
bundlerChain(chain) {
|
|
30
30
|
// Only register the plugin when RSDOCTOR is true, as the plugin will increase build time.
|
|
31
31
|
if (process.env.RSDOCTOR) {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
chain.plugin('rsdoctor').use(RsdoctorRspackPlugin, [
|
|
33
|
+
{
|
|
34
34
|
// Plugin options
|
|
35
|
-
}
|
|
36
|
-
);
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
},
|
|
@@ -5,6 +5,7 @@ sidebar_position: 15
|
|
|
5
5
|
# Deploy Application
|
|
6
6
|
|
|
7
7
|
Currently, Modern.js offers two deployment way:
|
|
8
|
+
|
|
8
9
|
- You can host your application in a container that includes a Node.js environment on your own, which provides flexibility for the deployment of the application.
|
|
9
10
|
- You can also deploy your application through a platform. Currently, Modern.js officially supports deployment on [Netlify](https://www.netlify.com/), [Vercel](https://vercel.com/), and [Github pages](https://pages.github.com/).
|
|
10
11
|
|
|
@@ -12,7 +13,6 @@ Currently, Modern.js offers two deployment way:
|
|
|
12
13
|
Currently, Modern.js only supports running in a Node.js environment. Support for more runtime environments will be provided in the future.
|
|
13
14
|
:::
|
|
14
15
|
|
|
15
|
-
|
|
16
16
|
## Build Deployment Products
|
|
17
17
|
|
|
18
18
|
Running the `modern deploy` command will automatically produce deployment products. This process includes optimizing Bundler build products and their dependencies, detecting the current deployment platform, and automatically generating deployment products that can run on that platform.
|
|
@@ -50,11 +50,12 @@ At this point, you can run the entire server by `node .output/index`, and the st
|
|
|
50
50
|
|
|
51
51
|
:::info
|
|
52
52
|
By default, when running Modern.js Server, it listens on port 8080. If you want to change the listening port, you can specify the `PORT` environment variable:
|
|
53
|
+
|
|
53
54
|
```
|
|
54
55
|
PORT=3000 node .output/index
|
|
55
56
|
```
|
|
56
|
-
:::
|
|
57
57
|
|
|
58
|
+
:::
|
|
58
59
|
|
|
59
60
|
### Monorepo
|
|
60
61
|
|
|
@@ -66,7 +67,7 @@ Assume that the name in the `package.json` of the current project is `app`. Taki
|
|
|
66
67
|
{
|
|
67
68
|
"scripts": {
|
|
68
69
|
"build:packages": "pnpm --filter 'app^...' run build",
|
|
69
|
-
"deploy": "pnpm run build:packages && modern deploy"
|
|
70
|
+
"deploy": "pnpm run build:packages && modern deploy"
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
```
|
|
@@ -77,7 +78,7 @@ If you use Rush as your Monorepo management tool, you can add the following comm
|
|
|
77
78
|
{
|
|
78
79
|
"scripts": {
|
|
79
80
|
"build:packages": "rush rebuild --to-except app",
|
|
80
|
-
"deploy": "rushx build:packages && modern deploy"
|
|
81
|
+
"deploy": "rushx build:packages && modern deploy"
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
```
|
|
@@ -134,12 +135,12 @@ Full-stack projects refer to projects that use Custom Web Server, SSR or BFF. Th
|
|
|
134
135
|
```
|
|
135
136
|
|
|
136
137
|
:::info
|
|
138
|
+
|
|
137
139
|
1. Currently, Modern.js does not support deployment on Netlify Edge Functions. We will support it in future versions.
|
|
138
140
|
2. You can refer to the [deployment project example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-ssr).
|
|
139
141
|
|
|
140
142
|
:::
|
|
141
143
|
|
|
142
|
-
|
|
143
144
|
### Monorepo
|
|
144
145
|
|
|
145
146
|
:::info
|
|
@@ -172,10 +173,9 @@ Add the following script in `packages/app/package.json`, before executing the de
|
|
|
172
173
|
{
|
|
173
174
|
"scripts": {
|
|
174
175
|
"build:packages": "pnpm --filter 'app^...' run build",
|
|
175
|
-
"deploy": "pnpm run build:packages && modern deploy"
|
|
176
|
+
"deploy": "pnpm run build:packages && modern deploy"
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
|
-
|
|
179
179
|
```
|
|
180
180
|
|
|
181
181
|
Configure the build command in `netlify.toml`:
|
|
@@ -200,6 +200,7 @@ Vercel is a deployment platform for modern web applications that provides a rich
|
|
|
200
200
|
### Pure Front-end Project
|
|
201
201
|
|
|
202
202
|
Add the `vercel.json` file to the root directory of the current project:
|
|
203
|
+
|
|
203
204
|
```bash
|
|
204
205
|
./
|
|
205
206
|
├── src
|
|
@@ -209,6 +210,7 @@ Add the `vercel.json` file to the root directory of the current project:
|
|
|
209
210
|
```
|
|
210
211
|
|
|
211
212
|
Add the following content to `vercel.json`:
|
|
213
|
+
|
|
212
214
|
```json title="vercel.json"
|
|
213
215
|
{
|
|
214
216
|
"buildCommand": "modern deploy",
|
|
@@ -265,13 +267,13 @@ First, you need to configure the **Root Directory** as `packages/app` on the Ver
|
|
|
265
267
|
|
|
266
268
|
<img src="https://sf16-sg.tiktokcdn.com/obj/eden-sg/lmeh7nuptpfnuhd/vercel-root-directory.png" />
|
|
267
269
|
|
|
268
|
-
Specify Node.js runtime as `
|
|
270
|
+
Specify Node.js runtime as `20.x`:
|
|
269
271
|
|
|
270
272
|
```json title="package.json"
|
|
271
273
|
"engines": {
|
|
272
|
-
"node": "
|
|
274
|
+
"node": "20.x"
|
|
273
275
|
}
|
|
274
|
-
|
|
276
|
+
```
|
|
275
277
|
|
|
276
278
|
Add the following script to `packages/app/package.json` to run `build` command of the other repositories in the workspace before run the `deploy` command for the `app` repository:
|
|
277
279
|
|
|
@@ -279,7 +281,7 @@ Add the following script to `packages/app/package.json` to run `build` command o
|
|
|
279
281
|
{
|
|
280
282
|
"scripts": {
|
|
281
283
|
"build:packages": "pnpm --filter 'app^...' run build",
|
|
282
|
-
"deploy": "pnpm run build:packages && modern deploy"
|
|
284
|
+
"deploy": "pnpm run build:packages && modern deploy"
|
|
283
285
|
}
|
|
284
286
|
}
|
|
285
287
|
```
|
|
@@ -305,11 +307,11 @@ import { defineConfig } from '@modern-js/app-tools';
|
|
|
305
307
|
export default defineConfig({
|
|
306
308
|
//...
|
|
307
309
|
server: {
|
|
308
|
-
baseUrl:
|
|
310
|
+
baseUrl: '/<repository-name>',
|
|
309
311
|
},
|
|
310
312
|
output: {
|
|
311
|
-
assetPrefix:
|
|
312
|
-
}
|
|
313
|
+
assetPrefix: '/<repository-name>',
|
|
314
|
+
},
|
|
313
315
|
});
|
|
314
316
|
```
|
|
315
317
|
|
|
@@ -320,6 +322,7 @@ For branch deployment, follow these steps:
|
|
|
320
322
|
1. In the GitHub repository, navigate to Settings > Pages > Source > Deploy from a branch
|
|
321
323
|
2. Install the `gh-pages` as devDependency
|
|
322
324
|
3. Add the following script to `package.json`
|
|
325
|
+
|
|
323
326
|
```
|
|
324
327
|
"scripts": {
|
|
325
328
|
//...
|
|
@@ -330,13 +333,13 @@ For branch deployment, follow these steps:
|
|
|
330
333
|
4. Run `npm run deploy:gh-pages`
|
|
331
334
|
|
|
332
335
|
:::info
|
|
336
|
+
|
|
333
337
|
1. Running `MODERNJS_DEPLOY=ghPages modern deploy` will build the production output for GitHub in the .output directory.
|
|
334
338
|
2. You can refer to the [project](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr)
|
|
335
|
-
:::
|
|
339
|
+
:::
|
|
336
340
|
|
|
337
341
|
For GitHub Actions deployment, select Settings > Pages > Source > GitHub Actions, and add a workflow file to the project. You can refer to the [example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr).
|
|
338
342
|
|
|
339
|
-
|
|
340
343
|
## Using Self-Built Node.js Server
|
|
341
344
|
|
|
342
345
|
Typically, we recommend using the built-in Node.js server of Modern.js to deploy applications. It supports hosting both pure frontend and full-stack projects, ensuring consistent performance in both development and production environments.
|
|
@@ -381,10 +384,14 @@ const app = new Koa();
|
|
|
381
384
|
app.use(async (ctx, next) => {
|
|
382
385
|
if (ctx.path.startsWith('/static')) {
|
|
383
386
|
ctx.type = mime.lookup(ctx.path);
|
|
384
|
-
ctx.body = fs.createReadStream(
|
|
387
|
+
ctx.body = fs.createReadStream(
|
|
388
|
+
path.resolve(__dirname, `.output${ctx.path}`),
|
|
389
|
+
);
|
|
385
390
|
} else if (ctx.path === '/') {
|
|
386
391
|
ctx.type = 'html';
|
|
387
|
-
ctx.body = fs.createReadStream(
|
|
392
|
+
ctx.body = fs.createReadStream(
|
|
393
|
+
path.resolve(__dirname, '.output/html/main/index.html'),
|
|
394
|
+
);
|
|
388
395
|
}
|
|
389
396
|
});
|
|
390
397
|
app.listen(3000);
|
|
@@ -40,7 +40,7 @@ Modern.js provides some components for rendering pages to help developers genera
|
|
|
40
40
|
import { Html, Body, Root, Head, Scripts } from '@modern-js/runtime/document';
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
- `Html`: provide the ability of native HTML Element and
|
|
43
|
+
- `Html`: provide the ability of native HTML Element and render necessary components that the developer did not add by default. `<Head>` and `<Body>` must exist, and other components can be assembled as needed.
|
|
44
44
|
|
|
45
45
|
- `Body`: provide the ability of native Body Element and needs to contain the `<Root>` component internally. It also supports other elements as child elements at the same time, such as adding footers.
|
|
46
46
|
|
|
@@ -47,8 +47,8 @@ Modern.js provides some configs to modify the directory or filename, you can:
|
|
|
47
47
|
- Modify the filename through [output.filename](/configure/app/output/filename).
|
|
48
48
|
- Modify the output path of through [output.distPath](/configure/app/output/dist-path).
|
|
49
49
|
- Modify the license file through [output.legalComments](/configure/app/output/legal-comments).
|
|
50
|
-
- Remove Source Map file through [output.
|
|
51
|
-
- Remove the folder corresponding to the HTML files through [html.
|
|
50
|
+
- Remove Source Map file through [output.sourceMap](/configure/app/output/source-map).
|
|
51
|
+
- Remove the folder corresponding to the HTML files through [html.outputStructure](/configure/app/html/output-structure).
|
|
52
52
|
|
|
53
53
|
## Static Assets
|
|
54
54
|
|
|
@@ -112,7 +112,7 @@ export default {
|
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
114
|
html: {
|
|
115
|
-
|
|
115
|
+
outputStructure: 'flat',
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
["ssr", "streaming-ssr", "ssr-cache", "ssg", "before-render"]
|
|
1
|
+
["overview", "ssr", "streaming-ssr", "ssr-cache", "ssg", "rsc", "before-render"]
|
|
@@ -5,12 +5,12 @@ In certain scenarios, applications need to perform preprocessing operations befo
|
|
|
5
5
|
## Defining a Runtime Plugin
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import type {
|
|
8
|
+
import type { RuntimePlugin } from '@modern-js/runtime';
|
|
9
9
|
|
|
10
|
-
const myRuntimePlugin = ():
|
|
10
|
+
const myRuntimePlugin = (): RuntimePlugin => ({
|
|
11
11
|
name: 'my-runtime-plugin',
|
|
12
|
-
setup:
|
|
13
|
-
api.onBeforeRender(
|
|
12
|
+
setup: api => {
|
|
13
|
+
api.onBeforeRender(context => {
|
|
14
14
|
// Logic to execute before rendering
|
|
15
15
|
console.log('Before rendering:', context);
|
|
16
16
|
});
|
|
@@ -35,23 +35,24 @@ export default defineRuntimeConfig({
|
|
|
35
35
|
|
|
36
36
|
## Use Case -- Global Data Injection
|
|
37
37
|
|
|
38
|
-
Through the `context` parameter of the `onBeforeRender` hook, you can inject global data into your application. Application components can access this data using the `
|
|
38
|
+
Through the `context` parameter of the `onBeforeRender` hook, you can inject global data into your application. Application components can access this data using the `use(RuntimeContext)` Hook.
|
|
39
39
|
|
|
40
40
|
:::info
|
|
41
41
|
|
|
42
42
|
This feature is particularly useful in the following scenarios:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
|
|
44
|
+
- Applications requiring page-level preliminary data
|
|
45
|
+
- Custom data injection workflows
|
|
46
|
+
- Framework migration scenarios (e.g., migrating from Next.js)
|
|
46
47
|
|
|
47
48
|
:::
|
|
48
49
|
|
|
49
50
|
**Defining a Data Injection Plugin**
|
|
50
51
|
|
|
51
52
|
```ts
|
|
52
|
-
import type {
|
|
53
|
+
import type { RuntimePlugin } from '@modern-js/runtime';
|
|
53
54
|
|
|
54
|
-
const dataInjectionPlugin = ():
|
|
55
|
+
const dataInjectionPlugin = (): RuntimePlugin => ({
|
|
55
56
|
name: 'data-injection-plugin',
|
|
56
57
|
setup: api => {
|
|
57
58
|
api.onBeforeRender(context => {
|
|
@@ -67,10 +68,11 @@ export default dataInjectionPlugin;
|
|
|
67
68
|
**Using Injected Data in Components**
|
|
68
69
|
|
|
69
70
|
```tsx
|
|
70
|
-
import {
|
|
71
|
+
import { use } from 'react';
|
|
72
|
+
import { RuntimeContext } from '@modern-js/runtime';
|
|
71
73
|
|
|
72
74
|
export default function MyComponent() {
|
|
73
|
-
const context =
|
|
75
|
+
const context = use(RuntimeContext);
|
|
74
76
|
const { message } = context;
|
|
75
77
|
|
|
76
78
|
return <div>{message}</div>;
|
|
@@ -82,9 +84,9 @@ export default function MyComponent() {
|
|
|
82
84
|
In SSR scenarios, the browser can access data injected via `onBeforeRender` during server-side rendering. Developers can decide whether to re-fetch data on the browser side to override server data based on their requirements.
|
|
83
85
|
|
|
84
86
|
```ts
|
|
85
|
-
import type {
|
|
87
|
+
import type { RuntimePlugin } from '@modern-js/runtime';
|
|
86
88
|
|
|
87
|
-
const dataInjectionPlugin = ():
|
|
89
|
+
const dataInjectionPlugin = (): RuntimePlugin => ({
|
|
88
90
|
name: 'data-injection-plugin',
|
|
89
91
|
setup: api => {
|
|
90
92
|
api.onBeforeRender(context => {
|
|
@@ -104,12 +106,3 @@ const dataInjectionPlugin = (): RuntimePluginFuture => ({
|
|
|
104
106
|
|
|
105
107
|
export default dataInjectionPlugin;
|
|
106
108
|
```
|
|
107
|
-
|
|
108
|
-
## Compatibility Notes
|
|
109
|
-
|
|
110
|
-
In earlier versions of Modern.js, it was possible to add render preprocessing logic through the `init` hook in `routes/layout.tsx` and the `App.init` method. These approaches are still **supported**, but we **strongly recommend** implementing with Runtime plugins instead.
|
|
111
|
-
|
|
112
|
-
:::warning
|
|
113
|
-
|
|
114
|
-
In future versions, the `init` hook in `routes/layout.tsx` and the `App.init` method will be gradually **deprecated**. We recommend migrating to the Runtime plugin approach as soon as possible.
|
|
115
|
-
:::
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Rendering Mode Overview
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Rendering Mode Overview
|
|
6
|
+
|
|
7
|
+
Modern.js supports multiple rendering modes, and different rendering modes are suitable for different scenarios. Choosing the right rendering mode can significantly improve application performance and user experience.
|
|
8
|
+
|
|
9
|
+
## Rendering Mode Quick Reference
|
|
10
|
+
|
|
11
|
+
| Rendering Mode | Characteristics | Use Cases |
|
|
12
|
+
|----------------|-----------------|-----------|
|
|
13
|
+
| **CSR** | Executes JavaScript in the browser to render pages | Applications with strong interactivity and low SEO requirements |
|
|
14
|
+
| **SSR** | Pre-renders complete HTML pages on the server | Websites with high requirements for first-screen performance and SEO |
|
|
15
|
+
| **Streaming SSR** | Renders and returns progressively, displaying initial UI faster | Applications requiring faster first-screen perception speed (**Default SSR mode**) |
|
|
16
|
+
| **RSC** | Components render on the server, reducing client JS size; high cohesion between data and component logic, reducing state passing | Projects pursuing optimal performance and needing to reduce client-side code |
|
|
17
|
+
| **SSG** | Generates static pages at build time, can be cached by CDN | Websites with relatively static content, such as blogs and documentation sites |
|
|
18
|
+
|
|
19
|
+
## Performance Comparison
|
|
20
|
+
|
|
21
|
+
| Rendering Technology | Core Advantages | Main Bottlenecks |
|
|
22
|
+
|---------------------|-----------------|------------------|
|
|
23
|
+
| **SSR** | Server-side pre-rendering, beneficial for SEO | Must wait for all data to load before responding |
|
|
24
|
+
| **Streaming SSR** | Renders and returns progressively, faster first screen | JS bundle size is still large |
|
|
25
|
+
| **Streaming SSR + RSC** | Reduces client JS size | - |
|
|
26
|
+
|
|
27
|
+
## How to Choose
|
|
28
|
+
|
|
29
|
+
### Quick Decision Guide
|
|
30
|
+
|
|
31
|
+
- **Static Content + SEO Required** → **SSG**
|
|
32
|
+
- **SEO Required + First Screen Performance** → **Streaming SSR** (default)
|
|
33
|
+
- **Pursuing Optimal Performance** → **Streaming SSR + RSC**
|
|
34
|
+
- **CSR Project Gradual Optimization** → **CSR + RSC**
|
|
35
|
+
- **Highly Interactive + No SEO Needed** → **CSR**
|
|
36
|
+
|
|
37
|
+
### Combining Modes
|
|
38
|
+
|
|
39
|
+
Modern.js supports combining multiple rendering modes:
|
|
40
|
+
|
|
41
|
+
- **Streaming SSR + RSC**: Streaming rendering + reduced client-side code
|
|
42
|
+
- **SSG + SSR**: Some pages static, some pages dynamic
|
|
43
|
+
- **CSR + RSC**: Client-side rendering + partial Server Components
|
|
44
|
+
|
|
45
|
+
## Related Documentation
|
|
46
|
+
|
|
47
|
+
- [Server-Side Rendering (SSR)](/guides/basic-features/render/ssr)
|
|
48
|
+
- [Streaming Server-Side Rendering (Streaming SSR)](/guides/basic-features/render/streaming-ssr)
|
|
49
|
+
- [React Server Components (RSC)](/guides/basic-features/render/rsc)
|
|
50
|
+
- [Static Site Generation (SSG)](/guides/basic-features/render/ssg)
|
|
51
|
+
- [Rendering Cache](/guides/basic-features/render/ssr-cache)
|