@modern-js/main-doc 3.9.3 → 3.10.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.
Files changed (197) hide show
  1. package/docs/en/apis/app/hooks/api/lambda.mdx +2 -1
  2. package/docs/en/apis/app/hooks/config/html.mdx +1 -0
  3. package/docs/en/apis/app/hooks/config/mock.mdx +1 -0
  4. package/docs/en/apis/app/hooks/config/public.mdx +1 -0
  5. package/docs/en/apis/app/hooks/config/upload.mdx +2 -3
  6. package/docs/en/apis/app/hooks/modern-config.mdx +1 -0
  7. package/docs/en/apis/app/hooks/shared.mdx +1 -0
  8. package/docs/en/apis/app/hooks/src/modern.runtime.mdx +1 -0
  9. package/docs/en/apis/app/hooks/src/routes.mdx +1 -0
  10. package/docs/en/apis/app/hooks/src/server.mdx +2 -1
  11. package/docs/en/apis/app/runtime/bff/use-hono-context.mdx +1 -0
  12. package/docs/en/apis/app/runtime/core/create-root.mdx +4 -1
  13. package/docs/en/apis/app/runtime/core/render.mdx +6 -2
  14. package/docs/en/apis/app/runtime/core/runtime-context.mdx +17 -17
  15. package/docs/en/apis/app/runtime/router/router.mdx +9 -6
  16. package/docs/en/apis/app/runtime/ssr/no-ssr.mdx +1 -0
  17. package/docs/en/apis/app/runtime/utility/head.mdx +1 -0
  18. package/docs/en/apis/app/runtime/utility/loadable.mdx +1 -0
  19. package/docs/en/community/blog/v3-release-note.mdx +36 -27
  20. package/docs/en/community/contributing-guide.mdx +15 -33
  21. package/docs/en/components/default-browserslist.mdx +0 -1
  22. package/docs/en/components/deploy-command.mdx +1 -1
  23. package/docs/en/components/deploy.mdx +1 -1
  24. package/docs/en/components/entry-scan-logic.mdx +1 -1
  25. package/docs/en/components/init-app.mdx +9 -3
  26. package/docs/en/components/international/custom-instance-code.mdx +0 -1
  27. package/docs/en/components/micro-runtime-config.mdx +12 -9
  28. package/docs/en/components/nodeVersion.mdx +2 -2
  29. package/docs/en/components/rsc-deploy-tip.mdx +0 -1
  30. package/docs/en/components/ssr-monitor.mdx +1 -1
  31. package/docs/en/configure/app/bff/cross-project.mdx +2 -2
  32. package/docs/en/configure/app/bff/prefix.mdx +1 -1
  33. package/docs/en/configure/app/dev/lazy-compilation.mdx +17 -1
  34. package/docs/en/configure/app/dev/start-url.mdx +0 -1
  35. package/docs/en/configure/app/output/css-modules.mdx +1 -5
  36. package/docs/en/configure/app/output/dist-path.mdx +0 -1
  37. package/docs/en/configure/app/output/inline-scripts.mdx +1 -2
  38. package/docs/en/configure/app/output/inline-styles.mdx +1 -2
  39. package/docs/en/configure/app/output/split-route-chunks.mdx +1 -1
  40. package/docs/en/configure/app/output/ssg.mdx +1 -1
  41. package/docs/en/configure/app/output/ssgByEntries.mdx +1 -0
  42. package/docs/en/configure/app/performance/chunk-split.mdx +1 -4
  43. package/docs/en/configure/app/runtime/plugins.mdx +6 -4
  44. package/docs/en/configure/app/server/rsc.mdx +1 -1
  45. package/docs/en/configure/app/server/ssr.mdx +7 -8
  46. package/docs/en/configure/app/server/tsconfig-path.mdx +2 -2
  47. package/docs/en/configure/app/tools/less.mdx +5 -6
  48. package/docs/en/configure/app/tools/sass.mdx +5 -6
  49. package/docs/en/configure/app/tools/svgr.mdx +7 -7
  50. package/docs/en/configure/app/usage.mdx +1 -5
  51. package/docs/en/guides/advanced-features/bff/cross-project.mdx +5 -4
  52. package/docs/en/guides/advanced-features/compatibility.mdx +0 -1
  53. package/docs/en/guides/advanced-features/international/advanced.mdx +1 -1
  54. package/docs/en/guides/advanced-features/international/api.mdx +34 -28
  55. package/docs/en/guides/advanced-features/international/best-practices.mdx +15 -15
  56. package/docs/en/guides/advanced-features/international/configuration.mdx +37 -37
  57. package/docs/en/guides/advanced-features/international/locale-detection.mdx +37 -28
  58. package/docs/en/guides/advanced-features/international/resource-loading.mdx +19 -17
  59. package/docs/en/guides/advanced-features/international/routing.mdx +8 -6
  60. package/docs/en/guides/advanced-features/international.mdx +8 -8
  61. package/docs/en/guides/advanced-features/server-monitor/logger.mdx +5 -5
  62. package/docs/en/guides/advanced-features/server-monitor/metrics.mdx +8 -8
  63. package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +1 -3
  64. package/docs/en/guides/advanced-features/source-build.mdx +1 -1
  65. package/docs/en/guides/advanced-features/web-server.mdx +3 -3
  66. package/docs/en/guides/basic-features/data/data-fetch.mdx +1 -3
  67. package/docs/en/guides/basic-features/data/data-write.mdx +24 -28
  68. package/docs/en/guides/basic-features/debug/mock.mdx +2 -2
  69. package/docs/en/guides/basic-features/debug/using-storybook.mdx +5 -6
  70. package/docs/en/guides/basic-features/html.mdx +2 -3
  71. package/docs/en/guides/basic-features/output-files.mdx +1 -1
  72. package/docs/en/guides/basic-features/render/overview.mdx +12 -12
  73. package/docs/en/guides/basic-features/render/rsc.mdx +16 -9
  74. package/docs/en/guides/basic-features/render/ssr-cache.mdx +5 -5
  75. package/docs/en/guides/basic-features/render/ssr.mdx +8 -12
  76. package/docs/en/guides/basic-features/render/streaming-ssr.mdx +2 -1
  77. package/docs/en/guides/basic-features/routes/config-routes.mdx +60 -59
  78. package/docs/en/guides/basic-features/testing/playwright.mdx +14 -8
  79. package/docs/en/guides/basic-features/testing/rstest.mdx +6 -4
  80. package/docs/en/guides/get-started/ai-coding-agents.mdx +6 -6
  81. package/docs/en/guides/get-started/introduction.mdx +0 -1
  82. package/docs/en/guides/topic-detail/module-federation/deploy.mdx +2 -2
  83. package/docs/en/guides/topic-detail/module-federation/introduce.mdx +0 -1
  84. package/docs/en/guides/upgrade/config.mdx +12 -0
  85. package/docs/en/guides/upgrade/other.mdx +4 -4
  86. package/docs/en/guides/upgrade/tailwindcss.mdx +0 -1
  87. package/docs/en/guides/upgrade/web-server.md +34 -17
  88. package/docs/en/index.md +1 -0
  89. package/docs/en/plugin/cli-plugins/api.mdx +23 -23
  90. package/docs/en/plugin/cli-plugins/life-cycle.mdx +2 -0
  91. package/docs/en/plugin/introduction.mdx +6 -6
  92. package/docs/en/plugin/official/cli-plugins/plugin-bff.mdx +1 -1
  93. package/docs/en/plugin/official/cli-plugins/plugin-ssg.mdx +1 -1
  94. package/docs/en/plugin/plugin-system.mdx +19 -26
  95. package/docs/en/plugin/runtime-plugins/life-cycle.mdx +2 -0
  96. package/docs/en/plugin/server-plugins/api.mdx +11 -14
  97. package/docs/en/plugin/server-plugins/life-cycle.mdx +2 -0
  98. package/docs/zh/apis/app/hooks/api/lambda.mdx +1 -1
  99. package/docs/zh/apis/app/hooks/config/html.mdx +1 -0
  100. package/docs/zh/apis/app/hooks/config/mock.mdx +1 -0
  101. package/docs/zh/apis/app/hooks/config/public.mdx +1 -0
  102. package/docs/zh/apis/app/hooks/config/upload.mdx +2 -3
  103. package/docs/zh/apis/app/hooks/modern-config.mdx +1 -0
  104. package/docs/zh/apis/app/hooks/shared.mdx +1 -0
  105. package/docs/zh/apis/app/hooks/src/modern.runtime.mdx +1 -0
  106. package/docs/zh/apis/app/hooks/src/routes.mdx +1 -0
  107. package/docs/zh/apis/app/hooks/src/server.mdx +2 -1
  108. package/docs/zh/apis/app/runtime/bff/use-hono-context.mdx +1 -1
  109. package/docs/zh/apis/app/runtime/core/create-root.mdx +4 -1
  110. package/docs/zh/apis/app/runtime/core/render.mdx +6 -3
  111. package/docs/zh/apis/app/runtime/core/runtime-context.mdx +17 -17
  112. package/docs/zh/apis/app/runtime/router/router.mdx +10 -6
  113. package/docs/zh/apis/app/runtime/ssr/no-ssr.mdx +1 -0
  114. package/docs/zh/apis/app/runtime/utility/head.mdx +1 -0
  115. package/docs/zh/apis/app/runtime/utility/loadable.mdx +1 -0
  116. package/docs/zh/community/blog/v3-release-note.mdx +38 -29
  117. package/docs/zh/community/contributing-guide.mdx +16 -34
  118. package/docs/zh/components/default-browserslist.mdx +0 -1
  119. package/docs/zh/components/deploy-command.mdx +1 -1
  120. package/docs/zh/components/deploy.mdx +1 -1
  121. package/docs/zh/components/entry-scan-logic.mdx +1 -1
  122. package/docs/zh/components/init-app.mdx +9 -3
  123. package/docs/zh/components/international/custom-instance-code.mdx +0 -1
  124. package/docs/zh/components/international/install-command.mdx +0 -1
  125. package/docs/zh/components/micro-runtime-config.mdx +12 -9
  126. package/docs/zh/components/nodeVersion.mdx +2 -2
  127. package/docs/zh/components/rsc-deploy-tip.mdx +0 -1
  128. package/docs/zh/components/ssr-monitor.mdx +1 -1
  129. package/docs/zh/configure/app/bff/cross-project.mdx +2 -2
  130. package/docs/zh/configure/app/bff/prefix.mdx +1 -1
  131. package/docs/zh/configure/app/dev/lazy-compilation.mdx +17 -1
  132. package/docs/zh/configure/app/html/crossorigin.mdx +0 -1
  133. package/docs/zh/configure/app/html/favicon.mdx +0 -1
  134. package/docs/zh/configure/app/output/convert-to-rem.mdx +0 -1
  135. package/docs/zh/configure/app/output/css-modules.mdx +1 -5
  136. package/docs/zh/configure/app/output/inline-scripts.mdx +1 -2
  137. package/docs/zh/configure/app/output/inline-styles.mdx +1 -2
  138. package/docs/zh/configure/app/output/source-map.mdx +0 -2
  139. package/docs/zh/configure/app/output/split-route-chunks.mdx +1 -1
  140. package/docs/zh/configure/app/output/ssg.mdx +1 -0
  141. package/docs/zh/configure/app/output/ssgByEntries.mdx +1 -1
  142. package/docs/zh/configure/app/performance/chunk-split.mdx +1 -4
  143. package/docs/zh/configure/app/resolve/dedupe.mdx +0 -1
  144. package/docs/zh/configure/app/runtime/plugins.mdx +6 -4
  145. package/docs/zh/configure/app/server/rsc.mdx +1 -1
  146. package/docs/zh/configure/app/server/ssr.mdx +6 -7
  147. package/docs/zh/configure/app/server/tsconfig-path.mdx +2 -2
  148. package/docs/zh/configure/app/tools/less.mdx +6 -7
  149. package/docs/zh/configure/app/tools/sass.mdx +6 -7
  150. package/docs/zh/configure/app/tools/svgr.mdx +11 -11
  151. package/docs/zh/configure/app/usage.mdx +1 -5
  152. package/docs/zh/guides/advanced-features/bff.mdx +1 -0
  153. package/docs/zh/guides/advanced-features/international/advanced.mdx +1 -1
  154. package/docs/zh/guides/advanced-features/international/api.mdx +28 -27
  155. package/docs/zh/guides/advanced-features/international/best-practices.mdx +15 -15
  156. package/docs/zh/guides/advanced-features/international/configuration.mdx +38 -36
  157. package/docs/zh/guides/advanced-features/international/locale-detection.mdx +37 -28
  158. package/docs/zh/guides/advanced-features/international/resource-loading.mdx +20 -16
  159. package/docs/zh/guides/advanced-features/international/routing.mdx +6 -4
  160. package/docs/zh/guides/advanced-features/international.mdx +9 -9
  161. package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +4 -6
  162. package/docs/zh/guides/advanced-features/server-monitor/metrics.mdx +9 -10
  163. package/docs/zh/guides/advanced-features/source-build.mdx +1 -1
  164. package/docs/zh/guides/advanced-features/web-server.mdx +3 -3
  165. package/docs/zh/guides/basic-features/data/data-fetch.mdx +1 -3
  166. package/docs/zh/guides/basic-features/data/data-write.mdx +25 -31
  167. package/docs/zh/guides/basic-features/debug/mock.mdx +2 -2
  168. package/docs/zh/guides/basic-features/debug/using-storybook.mdx +5 -5
  169. package/docs/zh/guides/basic-features/env-vars.mdx +0 -1
  170. package/docs/zh/guides/basic-features/html.mdx +2 -3
  171. package/docs/zh/guides/basic-features/render/overview.mdx +12 -13
  172. package/docs/zh/guides/basic-features/render/rsc.mdx +16 -9
  173. package/docs/zh/guides/basic-features/render/ssr.mdx +8 -17
  174. package/docs/zh/guides/basic-features/routes/config-routes.mdx +61 -59
  175. package/docs/zh/guides/basic-features/testing/playwright.mdx +15 -10
  176. package/docs/zh/guides/basic-features/testing/rstest.mdx +6 -4
  177. package/docs/zh/guides/get-started/ai-coding-agents.mdx +7 -7
  178. package/docs/zh/guides/topic-detail/module-federation/deploy.mdx +2 -2
  179. package/docs/zh/guides/upgrade/config.mdx +12 -0
  180. package/docs/zh/guides/upgrade/other.md +4 -11
  181. package/docs/zh/guides/upgrade/overview.mdx +1 -4
  182. package/docs/zh/guides/upgrade/tailwindcss.mdx +0 -1
  183. package/docs/zh/guides/upgrade/web-server.md +34 -19
  184. package/docs/zh/index.md +1 -0
  185. package/docs/zh/plugin/cli-plugins/api.mdx +24 -24
  186. package/docs/zh/plugin/cli-plugins/life-cycle.mdx +2 -0
  187. package/docs/zh/plugin/introduction.mdx +6 -6
  188. package/docs/zh/plugin/official/cli-plugins/plugin-bff.mdx +1 -1
  189. package/docs/zh/plugin/official/cli-plugins/plugin-ssg.mdx +1 -1
  190. package/docs/zh/plugin/plugin-system.mdx +19 -26
  191. package/docs/zh/plugin/runtime-plugins/life-cycle.mdx +2 -0
  192. package/docs/zh/plugin/server-plugins/api.mdx +11 -14
  193. package/docs/zh/plugin/server-plugins/life-cycle.mdx +2 -0
  194. package/package.json +11 -13
  195. package/{rspress.config.ts → rstack.config.mts} +7 -10
  196. package/src/components/Footer/styles.module.scss +1 -1
  197. package/src/components/SolutionCards/index.module.scss +3 -1
@@ -2,7 +2,8 @@
2
2
  title: lambda/*.ts
3
3
  sidebar_position: 3
4
4
  ---
5
- # lambda/*.ts
5
+
6
+ # lambda/\*.ts
6
7
 
7
8
  After enabling BFF, the files under the `lambda/` directory will be registered as BFF routes according to conventions.
8
9
 
@@ -2,6 +2,7 @@
2
2
  title: html/
3
3
  sidebar_position: 1
4
4
  ---
5
+
5
6
  # html/
6
7
 
7
8
  You can inject custom HTML fragments at different locations of the default internal HTML template through the `config/html` directory.
@@ -2,6 +2,7 @@
2
2
  title: mock/
3
3
  sidebar_position: 5
4
4
  ---
5
+
5
6
  # mock/
6
7
 
7
8
  When there is a `config/mock/index.ts` or `config/mock/index.js` file in the
@@ -2,6 +2,7 @@
2
2
  title: public/
3
3
  sidebar_position: 3
4
4
  ---
5
+
5
6
  # public/
6
7
 
7
8
  Any static assets can be placed in the `public/` directory, and the files will be deployed to the corresponding application domain by the server.
@@ -2,6 +2,7 @@
2
2
  title: upload/
3
3
  sidebar_position: 4
4
4
  ---
5
+
5
6
  # upload/
6
7
 
7
8
  Any static assets can be placed in the `upload/` directory.
@@ -30,9 +31,7 @@ In React components, you can add this prefix through [Environment Variables](/gu
30
31
 
31
32
  ```tsx
32
33
  export default () => {
33
- return (
34
- <img src={`${process.env.ASSET_PREFIX}/upload/banner.png`}></img>
35
- );
34
+ return <img src={`${process.env.ASSET_PREFIX}/upload/banner.png`}></img>;
36
35
  };
37
36
  ```
38
37
 
@@ -2,6 +2,7 @@
2
2
  title: modern.config.ts
3
3
  sidebar_position: 8
4
4
  ---
5
+
5
6
  # modern.config.ts
6
7
 
7
8
  The Modern.js configuration file. Through this file, you can personalize the configuration of various aspects of the current project.
@@ -2,6 +2,7 @@
2
2
  title: shared/
3
3
  sidebar_position: 5
4
4
  ---
5
+
5
6
  # shared/
6
7
 
7
8
  Shared source code directory. When there is common code in `api/`, `server/`, and `src/` in the project, you can put these codes in the `shared` directory instead of directly referencing them.
@@ -2,6 +2,7 @@
2
2
  title: modern.runtime.ts
3
3
  sidebar_position: 4
4
4
  ---
5
+
5
6
  # modern.runtime.ts
6
7
 
7
8
  The Modern.js Runtime configuration file allows for personalized configuration of the Runtime capabilities for the current project.
@@ -2,6 +2,7 @@
2
2
  title: routes/
3
3
  sidebar_position: 2
4
4
  ---
5
+
5
6
  # routes/
6
7
 
7
8
  The identifier for the entry point when the application uses [Conventional Routing](/guides/basic-features/routes/routes#conventional-routing).
@@ -2,6 +2,7 @@
2
2
  title: '*.[server|node].tsx'
3
3
  sidebar_position: 8
4
4
  ---
5
- # *.[server|node].tsx
5
+
6
+ # \*.[server|node].tsx
6
7
 
7
8
  Used in the application project to place server-side code. When `*.tsx` and `*.[server|node].tsx` coexist, SSR will prefer to use the `*.[server|node].tsx` file instead of the `*.tsx` file when rendering on the server.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: useHonoContext
3
3
  ---
4
+
4
5
  # useHonoContext
5
6
 
6
7
  Used to obtain Hono context in an integrated BFF function.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: createRoot
3
3
  ---
4
+
4
5
  # createRoot
5
6
 
6
7
  It is used to create the root component provided by Modern.js, which will automatically register Runtime plugins and complete the initialization of Runtime plugins.
@@ -14,7 +15,9 @@ import { createRoot } from '@modern-js/runtime/react';
14
15
  ## Function Signature
15
16
 
16
17
  ```ts
17
- export function createRoot(UserApp?: React.ComponentType | null): React.ComponentType<any>;
18
+ export function createRoot(
19
+ UserApp?: React.ComponentType | null,
20
+ ): React.ComponentType<any>;
18
21
  ```
19
22
 
20
23
  ### Parameters
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: render
3
3
  ---
4
+
4
5
  # render
5
6
 
6
7
  It is used to render project components.
@@ -16,7 +17,10 @@ render(<ModernRoot />);
16
17
  ## Function Signature
17
18
 
18
19
  ```ts
19
- export function render(App: React.ReactElement, id?: HTMLElement | string): Promise<any>;
20
+ export function render(
21
+ App: React.ReactElement,
22
+ id?: HTMLElement | string,
23
+ ): Promise<any>;
20
24
  ```
21
25
 
22
26
  ### Parameters
@@ -33,7 +37,7 @@ import { render } from '@modern-js/runtime/browser';
33
37
  const ModernRoot = createRoot();
34
38
 
35
39
  async function beforeRender() {
36
- // todo
40
+ // todo
37
41
  }
38
42
 
39
43
  beforeRender().then(() => {
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: RuntimeContext
3
3
  ---
4
+
4
5
  # RuntimeContext
5
6
 
6
7
  `RuntimeContext` is a React Context used to get Runtime context information in components. This Context can be accessed through React's `use` or `useContext` API.
@@ -19,7 +20,7 @@ import { RuntimeContext } from '@modern-js/runtime';
19
20
 
20
21
  export function App() {
21
22
  const runtimeContext = use(RuntimeContext); // You can also use useContext(RuntimeContext)
22
- return <div>Hello World</div>
23
+ return <div>Hello World</div>;
23
24
  }
24
25
  ```
25
26
 
@@ -53,21 +54,21 @@ type TRuntimeContext = {
53
54
  ```ts
54
55
  type RequestContext = {
55
56
  request: {
56
- params: Record<string, string>; // Route parameters
57
- pathname: string; // Pathname
58
- query: Record<string, string>; // Query parameters
59
- headers: IncomingHttpHeaders; // Request headers
60
- host: string; // Hostname
61
- url: string; // Full URL
62
- referer?: string; // Referrer page
63
- userAgent?: string; // User agent
64
- cookie?: string; // Cookie string
65
- cookieMap?: Record<string, string>; // Cookie map object
57
+ params: Record<string, string>; // Route parameters
58
+ pathname: string; // Pathname
59
+ query: Record<string, string>; // Query parameters
60
+ headers: IncomingHttpHeaders; // Request headers
61
+ host: string; // Hostname
62
+ url: string; // Full URL
63
+ referer?: string; // Referrer page
64
+ userAgent?: string; // User agent
65
+ cookie?: string; // Cookie string
66
+ cookieMap?: Record<string, string>; // Cookie map object
66
67
  };
67
68
  response: {
68
- setHeader: (key: string, value: string) => void; // Set response header (server-side only)
69
- status: (code: number) => void; // Set status code (server-side only)
70
- locals: Record<string, any>; // Local data
69
+ setHeader: (key: string, value: string) => void; // Set response header (server-side only)
70
+ status: (code: number) => void; // Set status code (server-side only)
71
+ locals: Record<string, any>; // Local data
71
72
  };
72
73
  };
73
74
  ```
@@ -91,11 +92,11 @@ function App() {
91
92
 
92
93
  if (isBrowser === true) {
93
94
  // Browser-side execution logic
94
- console.log('browser render')
95
+ console.log('browser render');
95
96
  } else {
96
97
  // Server-side execution logic
97
98
  // Note: Functions like logger need to be injected into context through Runtime plugins
98
- console.log('server render')
99
+ console.log('server render');
99
100
  }
100
101
  }
101
102
  ```
@@ -157,4 +158,3 @@ export default function MyComponent() {
157
158
  return <div>{message}</div>;
158
159
  }
159
160
  ```
160
-
@@ -136,8 +136,10 @@ export default ErrorBoundary;
136
136
  ```ts
137
137
  declare function Link(props: LinkProps): React.ReactElement;
138
138
 
139
- interface LinkProps
140
- extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
139
+ interface LinkProps extends Omit<
140
+ React.AnchorHTMLAttributes<HTMLAnchorElement>,
141
+ 'href'
142
+ > {
141
143
  replace?: boolean;
142
144
  state?: any;
143
145
  to: To;
@@ -158,12 +160,13 @@ A `<Link>` is an element that lets the user navigate to another page by clicking
158
160
  ```ts
159
161
  declare function NavLink(props: NavLinkProps): React.ReactElement;
160
162
 
161
- interface NavLinkProps
162
- extends Omit<LinkProps, 'className' | 'style' | 'children'> {
163
+ interface NavLinkProps extends Omit<
164
+ LinkProps,
165
+ 'className' | 'style' | 'children'
166
+ > {
163
167
  caseSensitive?: boolean;
164
168
  children?:
165
- | React.ReactNode
166
- | ((props: { isActive: boolean }) => React.ReactNode);
169
+ React.ReactNode | ((props: { isActive: boolean }) => React.ReactNode);
167
170
  className?: string | ((props: { isActive: boolean }) => string | undefined);
168
171
  end?: boolean;
169
172
  style?:
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: NoSSR
3
3
  ---
4
+
4
5
  # NoSSR
5
6
 
6
7
  The content wrapped by NoSSR will not be rendered at the server, nor will it be rendered during the client side hydrate. it will only be rendered immediately after the entire app is rendered.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: Head
3
3
  ---
4
+
4
5
  # Head
5
6
 
6
7
  Used to add html elements (such as title, meta, script, etc.) to the `<head>` element, supports SSR.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: loadable
3
3
  ---
4
+
4
5
  # loadable
5
6
 
6
7
  Used to create Loadable component
@@ -2,7 +2,6 @@
2
2
  title: Modern.js v3 Release
3
3
  ---
4
4
 
5
-
6
5
  # Modern.js v3 Release: Focused on web framework, embracing ecosystem development
7
6
 
8
7
  > Published on 2025.02.06
@@ -45,10 +44,10 @@ Modern.js 3.0 integrates React Server Component, supporting both CSR and SSR pro
45
44
 
46
45
  React Server Components (RSC) are a new type of component that allows **component logic to execute entirely on the server**, streaming the rendered UI directly to the client. Compared to traditional client components, Server Components offer the following benefits:
47
46
 
48
- | Feature | Description |
49
- | --- | --- |
50
- | Zero Client Bundle Size | Component code is not included in the client JS bundle — it only executes on the server, speeding up initial page load and rendering |
51
- | Higher Cohesion | Components can directly access databases, call internal APIs, and read local files, improving development efficiency |
47
+ | Feature | Description |
48
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49
+ | Zero Client Bundle Size | Component code is not included in the client JS bundle — it only executes on the server, speeding up initial page load and rendering |
50
+ | Higher Cohesion | Components can directly access databases, call internal APIs, and read local files, improving development efficiency |
52
51
  | Progressive Enhancement | Can be seamlessly mixed with client components, selectively offloading interactive logic to the client while maintaining high performance and supporting complex interactions |
53
52
 
54
53
  It's important to clarify that RSC and SSR are **fundamentally different concepts**:
@@ -68,7 +67,7 @@ In Modern.js 3.0, simply enable RSC in the configuration:
68
67
  export default defineConfig({
69
68
  server: {
70
69
  rsc: true,
71
- }
70
+ },
72
71
  });
73
72
  ```
74
73
 
@@ -76,7 +75,14 @@ export default defineConfig({
76
75
  Once enabled, all route components will default to Server Components. Some components in your project may not be able to run on the server — you can add the `'use client'` directive to those components to preserve their original behavior, and then migrate gradually.
77
76
  :::
78
77
 
79
- <video src="https://lf3-static.bytednsdoc.com/obj/eden-cn/nuvjhpqnuvr/rsc.mp4" controls autoplay loop muted style={{ width: '100%', borderRadius: 8 }} />
78
+ <video
79
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/nuvjhpqnuvr/rsc.mp4"
80
+ controls
81
+ autoplay
82
+ loop
83
+ muted
84
+ style={{ width: '100%', borderRadius: 8 }}
85
+ />
80
86
 
81
87
  #### RSC Features in Modern.js 3.0
82
88
 
@@ -157,7 +163,7 @@ import('./module').then(({ value }) => {
157
163
  });
158
164
 
159
165
  // Destructuring in function body
160
- import('./module').then((mod) => {
166
+ import('./module').then(mod => {
161
167
  const { value } = mod;
162
168
  console.log(value);
163
169
  });
@@ -237,7 +243,10 @@ In practice, we found that some projects need to extend the Web Server — for e
237
243
  In Modern.js 3.0, we rebuilt the Web Server using [Hono](https://hono.dev) and officially opened up server middleware and plugin capabilities. Developers can use Hono middleware to meet their needs:
238
244
 
239
245
  ```ts title="server/modern.server.ts"
240
- import { defineServerConfig, type MiddlewareHandler } from "@modern-js/server-runtime";
246
+ import {
247
+ defineServerConfig,
248
+ type MiddlewareHandler,
249
+ } from '@modern-js/server-runtime';
241
250
 
242
251
  const timingMiddleware: MiddlewareHandler = async (c, next) => {
243
252
  const start = Date.now();
@@ -250,8 +259,8 @@ const htmlMiddleware: MiddlewareHandler = async (c, next) => {
250
259
  await next();
251
260
  const html = await c.res.text();
252
261
  const modified = html.replace(
253
- "<head>",
254
- '<head><meta name="generator" content="Modern.js">'
262
+ '<head>',
263
+ '<head><meta name="generator" content="Modern.js">',
255
264
  );
256
265
  c.res = c.body(modified, { status: c.res.status, headers: c.res.headers });
257
266
  };
@@ -322,13 +331,13 @@ In Modern.js, we recommend using convention-based routing to organize code. Howe
322
331
  Therefore, Modern.js 3.0 provides full config-based routing support, which can be used alongside convention-based routing or independently.
323
332
 
324
333
  ```ts title="src/modern.routes.ts"
325
- import { defineRoutes } from "@modern-js/runtime/config-routes";
334
+ import { defineRoutes } from '@modern-js/runtime/config-routes';
326
335
 
327
336
  export default defineRoutes(({ route, layout, page }) => {
328
337
  return [
329
- route("home.tsx", "/"),
330
- route("about.tsx", "about"),
331
- route("blog.tsx", "blog/:id"),
338
+ route('home.tsx', '/'),
339
+ route('about.tsx', 'about'),
340
+ route('blog.tsx', 'blog/:id'),
332
341
  ];
333
342
  });
334
343
  ```
@@ -414,19 +423,19 @@ For render cache usage, see the docs: [Render Cache](/guides/basic-features/rend
414
423
  The new version provides a `cache` function that offers finer-grained data-level control compared to render cache. When multiple data requests depend on the same data, `cache` can avoid duplicate requests:
415
424
 
416
425
  ```ts title="server/loader.ts"
417
- import { cache } from "@modern-js/runtime/cache";
418
- import { fetchUserData, fetchUserProjects, fetchUserTeam } from "./api";
426
+ import { cache } from '@modern-js/runtime/cache';
427
+ import { fetchUserData, fetchUserProjects, fetchUserTeam } from './api';
419
428
 
420
429
  // Cache user data to avoid duplicate requests
421
430
  const getUser = cache(fetchUserData);
422
431
 
423
432
  const getProjects = async () => {
424
- const user = await getUser("test-user");
433
+ const user = await getUser('test-user');
425
434
  return fetchUserProjects(user.id);
426
435
  };
427
436
 
428
437
  const getTeam = async () => {
429
- const user = await getUser("test-user"); // Reuses cache, no duplicate request
438
+ const user = await getUser('test-user'); // Reuses cache, no duplicate request
430
439
  return fetchUserTeam(user.id);
431
440
  };
432
441
 
@@ -445,14 +454,14 @@ For more on data cache usage, see the docs: [Data Cache](/guides/basic-features/
445
454
 
446
455
  Through practice, we have developed multi-dimensional fallback strategies:
447
456
 
448
- | Type | Trigger | Fallback Behavior | Use Case |
449
- | --- | --- | --- | --- |
450
- | Error Fallback | Data Loader execution error | Triggers ErrorBoundary | Data request error handling |
451
- | Render Error | Server-side rendering error | Falls back to CSR, reusing existing data for rendering | SSR error handling |
452
- | Business Fallback | Loader throws `throw Response` | Triggers ErrorBoundary with corresponding HTTP status code | 404, permission checks, and other business scenarios |
453
- | Client Loader | Configure Client Loader | Bypasses SSR, requests data source directly | Scenarios requiring client-side data fetching |
454
- | Forced Fallback | Query parameter `?__csr=true` | Skips SSR, returns CSR page | Debugging, temporary fallback |
455
- | Forced Fallback | Request header `x-modern-ssr-fallback` | Skips SSR, returns CSR page | Gateway-level fallback control |
457
+ | Type | Trigger | Fallback Behavior | Use Case |
458
+ | ----------------- | -------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------- |
459
+ | Error Fallback | Data Loader execution error | Triggers ErrorBoundary | Data request error handling |
460
+ | Render Error | Server-side rendering error | Falls back to CSR, reusing existing data for rendering | SSR error handling |
461
+ | Business Fallback | Loader throws `throw Response` | Triggers ErrorBoundary with corresponding HTTP status code | 404, permission checks, and other business scenarios |
462
+ | Client Loader | Configure Client Loader | Bypasses SSR, requests data source directly | Scenarios requiring client-side data fetching |
463
+ | Forced Fallback | Query parameter `?__csr=true` | Skips SSR, returns CSR page | Debugging, temporary fallback |
464
+ | Forced Fallback | Request header `x-modern-ssr-fallback` | Skips SSR, returns CSR page | Gateway-level fallback control |
456
465
 
457
466
  ---
458
467
 
@@ -36,13 +36,6 @@ nvm alias default 22
36
36
  nvm use 22
37
37
  ```
38
38
 
39
- ### Install pnpm
40
-
41
- ```sh
42
- # Enable pnpm with corepack, only available on Node.js >= `v14.19.0`
43
- corepack enable
44
- ```
45
-
46
39
  ### Install Dependencies
47
40
 
48
41
  ```sh
@@ -57,28 +50,6 @@ What this will do:
57
50
 
58
51
  > A full rebuild of all packages is generally not required after this. If a new feature you are developing requires an updated version of another package, it is usually sufficient to build the changed dependencies.
59
52
 
60
- ### Set Git Email
61
-
62
- Please make sure you have your email set up in `<https://github.com/settings/emails>`. This will be needed later when you want to submit a pull request.
63
-
64
- Check that your git client is already configured the email:
65
-
66
- ```sh
67
- git config --list | grep email
68
- ```
69
-
70
- Set the email to global config:
71
-
72
- ```sh
73
- git config --global user.email "SOME_EMAIL@example.com"
74
- ```
75
-
76
- Set the email for local repo:
77
-
78
- ```sh
79
- git config user.email "SOME_EMAIL@example.com"
80
- ```
81
-
82
53
  ## Making Changes and Building
83
54
 
84
55
  Once you have set up the local development environment in your forked repo, we can start development.
@@ -132,7 +103,7 @@ Modern.js uses [Rstest](https://rstest.rs/) for unit tests across the repository
132
103
  Before submitting a pull request, it's important to make sure that the changes haven't introduced any regressions or bugs. You can run the unit tests for the project by executing the following command:
133
104
 
134
105
  ```sh
135
- pnpm run test
106
+ pnpm run test:ut
136
107
  ```
137
108
 
138
109
  Alternatively, you can run the unit tests of single package using the `--filter` option:
@@ -145,10 +116,11 @@ pnpm run --filter @modern-js/some-package test
145
116
 
146
117
  In addition to the unit tests, the Modern.js also includes end-to-end (E2E) tests, which checks the functionality of the application as a whole.
147
118
 
148
- You can run the `test:e2e` command to run the E2E tests:
119
+ Run the framework integration tests and Builder E2E tests with the following commands:
149
120
 
150
121
  ```sh
151
- pnpm run test:e2e
122
+ pnpm run test:framework
123
+ pnpm run test:builder
152
124
  ```
153
125
 
154
126
  If you need to run a specified test, you can add keywords to filter:
@@ -160,7 +132,7 @@ npx rstest copy-assets
160
132
 
161
133
  ## Linting
162
134
 
163
- To help maintain consistency and readability of the codebase, we use a ESLint to lint the codes.
135
+ To help maintain consistency and readability across the codebase, we use [Rstack CLI](https://rstack.rs/) for linting and formatting.
164
136
 
165
137
  You can run the Linter by executing the following command:
166
138
 
@@ -168,6 +140,14 @@ You can run the Linter by executing the following command:
168
140
  pnpm run lint
169
141
  ```
170
142
 
143
+ Run the formatter from the repository root:
144
+
145
+ ```sh
146
+ pnpm run format
147
+ ```
148
+
149
+ Append a file or directory path to either command to limit its scope.
150
+
171
151
  ## Benchmarking
172
152
 
173
153
  You can input `!bench-framework` or `!bench-module` in the comment area of ​​the PR to do benchmarking on `@modern-js/app-tools` and `@modern-js/module-tools` respectively (you need to have Collaborator and above permissions).
@@ -249,6 +229,8 @@ pnpm run prepare
249
229
  pnpm run bump
250
230
  ```
251
231
 
232
+ After Changesets updates the package versions, this command synchronizes internal `peerDependencies` ranges to `workspace:^<dependency version>` to satisfy the changeset validation.
233
+
252
234
  5. Commit the version change.
253
235
 
254
236
  ```sh
@@ -1,4 +1,3 @@
1
-
2
1
  ```yaml title=".browserslistrc"
3
2
  chrome >= 87
4
3
  edge >= 88
@@ -11,4 +11,4 @@ Options:
11
11
  -h, --help Display command help
12
12
  ```
13
13
 
14
- For more details, refer to [Deploy Application](/guides/basic-features/deploy).
14
+ For more details, refer to [Deploy Application](/guides/basic-features/deploy).
@@ -1 +1 @@
1
- After local develop, you can refer to the [Deployment](/guides/basic-features/deploy.html) section to deploy the project to the server.
1
+ After local develop, you can refer to the [Deployment](/guides/basic-features/deploy.html) section to deploy the project to the server.
@@ -1,7 +1,7 @@
1
1
  :::tip Entry scanning logic
2
+
2
3
  - If `src/` itself meets entry criteria → Single-entry application
3
4
  - If `src/` does not meet criteria → Scan subdirectories under `src/` → Multi-entry application
4
5
  - In single-entry applications, the default entry name is `index`
5
6
 
6
7
  :::
7
-
@@ -38,19 +38,18 @@ npx @modern-js/create@latest myapp
38
38
 
39
39
  ⚡ Start the development server:
40
40
 
41
- pnpm start
41
+ pnpm dev
42
42
  ```
43
43
 
44
44
  Now, the project structure is as follows:
45
45
 
46
46
  ```
47
47
  .
48
- ├── biome.json
49
48
  ├── modern.config.ts
50
49
  ├── package.json
51
50
  ├── README.md
51
+ ├── rstack.config.mts
52
52
  ├── src
53
- │ ├── modern-app-env.d.ts
54
53
  │ ├── modern.runtime.ts
55
54
  │ └── routes
56
55
  │ ├── index.css
@@ -58,3 +57,10 @@ Now, the project structure is as follows:
58
57
  │ └── page.tsx
59
58
  └── tsconfig.json
60
59
  ```
60
+
61
+ New standalone projects use [Rstack CLI](https://rstack.rs/) for linting and formatting:
62
+
63
+ ```bash
64
+ pnpm check
65
+ pnpm format
66
+ ```
@@ -13,4 +13,3 @@ export default defineRuntimeConfig({
13
13
  },
14
14
  });
15
15
  ```
16
-
@@ -3,15 +3,18 @@ import { defineRuntimeConfig } from '@modern-js/runtime';
3
3
 
4
4
  export default defineRuntimeConfig({
5
5
  masterApp: {
6
- apps: [{
7
- name: 'Table',
8
- entry: 'http://localhost:8081',
9
- // activeWhen: '/table'
10
- }, {
11
- name: 'Dashboard',
12
- entry: 'http://localhost:8082'
13
- // activeWhen: '/dashboard'
14
- }]
6
+ apps: [
7
+ {
8
+ name: 'Table',
9
+ entry: 'http://localhost:8081',
10
+ // activeWhen: '/table'
11
+ },
12
+ {
13
+ name: 'Dashboard',
14
+ entry: 'http://localhost:8082',
15
+ // activeWhen: '/dashboard'
16
+ },
17
+ ],
15
18
  },
16
19
  });
17
20
  ```
@@ -1,4 +1,4 @@
1
- Before getting started, you will need to install [Node.js](https://nodejs.org/), and ensure that your Node.js version is not lower than v20.19.5. **We recommend using the LTS version of Node.js 22.**
1
+ Before getting started, you will need to install [Node.js](https://nodejs.org/), and ensure that your Node.js version is not lower than v22.18.0. **We recommend using the LTS version of Node.js 22.**
2
2
 
3
3
  You can check the currently used Node.js version with the following command:
4
4
 
@@ -6,7 +6,7 @@ You can check the currently used Node.js version with the following command:
6
6
  node -v
7
7
  ```
8
8
 
9
- If you do not have Node.js installed in your current environment, or the installed version is lower than v20.19.5, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the required version.
9
+ If you do not have Node.js installed in your current environment, or the installed version does not meet this requirement, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the required version.
10
10
 
11
11
  Here is an example of how to install the Node.js 22 LTS version via nvm:
12
12
 
@@ -1 +0,0 @@
1
-
@@ -1,3 +1,3 @@
1
1
  :::tip
2
2
  SSR monitoring has been integrated into the Monitors module, see [Monitors](/guides/advanced-features/server-monitor/monitors) for details.
3
- :::
3
+ :::