For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /apis/app/hooks/src/app.md.

App.tsx

The entry identifier when using Self-controlled Routing in the application.

App.tsx is not the actual application entry; Modern.js will automatically generate the real entry file, which is roughly as follows:

// runtime-global-context
import { setGlobalContext } from '@modern-js/runtime/context';
import App from '@_modern_js_src/App';

setGlobalContext({
  App,
});

// index.tsx
import './runtime-global-context';
import { createRoot } from '@modern-js/runtime/react';
import { render } from '@modern-js/runtime/browser';

const ModernRoot = createRoot();

render(<ModernRoot />, 'root');

When createRoot is executed, it will retrieve the registered Global App and generate the actual React component.

Note

In scenarios with multiple entry points, each entry can have its own independent App.tsx. For more details, see Entry Points.