> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# @lynx-js/react

[npm](https://www.npmjs.com/package/@lynx-js/react) · [Source](https://github.com/lynx-family/lynx-stack/tree/main/packages/react) · [Changelog](https://github.com/lynx-family/lynx-stack/blob/main/packages/react/CHANGELOG.md)

`@lynx-js/react` is React for Lynx. It keeps the React 17 API surface,
re-exporting the standard hooks and APIs, and adds what the dual-thread
model needs: main-thread functions, the data a page receives from native,
and a few compile-time directives and macros.

## Remarks

The React APIs below behave as the
[official React reference](https://react.dev/reference/react)
describes them, unless a page says otherwise. They are compatible with
React 17 and [Preact](https://preactjs.com/guide/v10/switching-to-preact/).

React entered its "concurrent" era with
[React 18](https://react.dev/blog/2022/03/29/react-v18). Concurrent
features such as `useTransition` and `useDeferredValue` make strict demands
on how the host schedules work — they depend on browser Web APIs or on the
React Native architecture. Lynx evolves its own architecture, so ReactLynx
builds on React 17 and keeps the React programming model. The parts of
[React 19](https://react.dev/blog/2024/04/25/react-19) and the
[React Compiler](https://react.dev/learn/react-compiler) that do not
depend on the concurrent architecture are still on the table.

For an introduction to ReactLynx, see the
[ReactLynx guides](/next/react/index.md).

## Documents

- [Directives](/next/api/react/Documents/Directives.md)
- [Built-in macros](/next/api/react/Documents/Built-in_macros.md)
- [Global events](/next/api/react/Documents/Global_events.md)
- [Import attributes](/next/api/react/Documents/Import_attributes.md)

## Interfaces

- [MainThreadObjectHandle](/next/api/react/Interfaces/MainThreadObjectHandle.md)
- [MainThreadObjectType](/next/api/react/Interfaces/MainThreadObjectType.md)
- [MainThreadObjectTypeDefinition](/next/api/react/Interfaces/MainThreadObjectTypeDefinition.md)

## Functions

Functions for crossing the thread boundary, creating elements outside JSX
and mounting the root.

- [Children](/next/api/react/Functions/Children.md)
- [root](/next/api/react/Functions/root.md)
- [cloneElement](/next/api/react/Functions/cloneElement.md)
- [createContext](/next/api/react/Functions/createContext.md)
- [createElement](/next/api/react/Functions/createElement.md)
- [createPortal](/next/api/react/Functions/createPortal.md)
- [createRef](/next/api/react/Functions/createRef.md)
- [defineMainThreadObjectType](/next/api/react/Functions/defineMainThreadObjectType.md)
- [forwardRef](/next/api/react/Functions/forwardRef.md)
- [isValidElement](/next/api/react/Functions/isValidElement.md)
- [lazy](/next/api/react/Functions/lazy.md)
- [markFirstScreenSyncReady](/next/api/react/Functions/markFirstScreenSyncReady.md)
- [memo](/next/api/react/Functions/memo.md)
- [runOnBackground](/next/api/react/Functions/runOnBackground.md)
- [runOnMainThread](/next/api/react/Functions/runOnMainThread.md)
- [useMainThreadObject](/next/api/react/Functions/useMainThreadObject.md)
- [withInitDataInState](/next/api/react/Functions/withInitDataInState.md)

## Components

Provider and consumer components for the data a Lynx page receives from
the native side, and the components re-exported from React.

- [Component](/next/api/react/Components/Component.md)
- [PureComponent](/next/api/react/Components/PureComponent.md)
- [Fragment](/next/api/react/Components/Fragment.md)
- [GlobalPropsConsumer](/next/api/react/Components/GlobalPropsConsumer.md)
- [GlobalPropsProvider](/next/api/react/Components/GlobalPropsProvider.md)
- [InitDataConsumer](/next/api/react/Components/InitDataConsumer.md)
- [InitDataProvider](/next/api/react/Components/InitDataProvider.md)
- [Suspense](/next/api/react/Components/Suspense.md)

## Hooks

Hooks that ReactLynx adds on top of React, plus the React hooks it
re-exports or re-implements for the dual-thread model.

- [useCallback](/next/api/react/Hooks/useCallback.md)
- [useContext](/next/api/react/Hooks/useContext.md)
- [useDebugValue](/next/api/react/Hooks/useDebugValue.md)
- [useEffect](/next/api/react/Hooks/useEffect.md)
- [useErrorBoundary](/next/api/react/Hooks/useErrorBoundary.md)
- [useGlobalProps](/next/api/react/Hooks/useGlobalProps.md)
- [useGlobalPropsChanged](/next/api/react/Hooks/useGlobalPropsChanged.md)
- [useImperativeHandle](/next/api/react/Hooks/useImperativeHandle.md)
- [useInitData](/next/api/react/Hooks/useInitData.md)
- [useInitDataChanged](/next/api/react/Hooks/useInitDataChanged.md)
- [~~useLayoutEffect~~](/next/api/react/Hooks/useLayoutEffect.md)
- [useLynxGlobalEventListener](/next/api/react/Hooks/useLynxGlobalEventListener.md)
- [useMainThreadRef](/next/api/react/Hooks/useMainThreadRef.md)
- [useMemo](/next/api/react/Hooks/useMemo.md)
- [useReducer](/next/api/react/Hooks/useReducer.md)
- [useRef](/next/api/react/Hooks/useRef.md)
- [useState](/next/api/react/Hooks/useState.md)
- [useSyncExternalStore](/next/api/react/Hooks/useSyncExternalStore.md)

## Types

The types and classes exported by `@lynx-js/react`. Augment `InitData` and
`GlobalProps` in your project to type the data your page receives.

- [MainThreadRef](/next/api/react/Types/MainThreadRef.md)
- [CloneElement](/next/api/react/Types/CloneElement.md)
- [CreateElement](/next/api/react/Types/CreateElement.md)
- [DataProcessorDefinition](/next/api/react/Types/DataProcessorDefinition.md)
- [DataProcessors](/next/api/react/Types/DataProcessors.md)
- [GlobalProps](/next/api/react/Types/GlobalProps.md)
- [InitData](/next/api/react/Types/InitData.md)
- [InitDataRaw](/next/api/react/Types/InitDataRaw.md)
- [Lynx](/next/api/react/Types/Lynx.md)
- [Root](/next/api/react/Types/Root.md)
- [ReactLynxChildren](/next/api/react/Types/ReactLynxChildren.md)
