Installation
Install react-litert and its required dependencies.
npm
npm install react-litert
yarn
yarn add react-litert
pnpm
pnpm add react-litert
Peer Dependencies
react-litert requires React as a peer dependency. Make sure you have React installed:
npm install react
Optional Dependencies
TensorFlow.js (for tf.Tensor support)
If you want to use useLiteRtTfjsModel with TensorFlow.js tensors, install TensorFlow.js:
npm install @tensorflow/tfjs-core
The package includes TensorFlow.js backends (@tensorflow/tfjs-backend-webgpu and @tensorflow/tfjs-backend-cpu), so you don't need to install them separately.
LiteRT WASM Files
You'll need to include the LiteRT WASM files in your application. You can:
-
Copy from node_modules (recommended for development):
cp -r node_modules/@litertjs/core/dist/wasm public/litert-wasm -
Use a CDN (for production): Set
wasmRootin your provider config to point to a CDN URL. -
Bundle with your app: Configure your bundler to copy the WASM files to your output directory.
Verify Installation
Create a simple test component to verify everything is set up correctly:
import { LiteRtProvider } from 'react-litert';
function App() {
return (
<LiteRtProvider config={{ wasmRoot: '/litert-wasm/' }}>
<div>react-litert is installed!</div>
</LiteRtProvider>
);
}
If this renders without errors, you're ready to go!
Next Steps
- Basic Usage - Learn how to use react-litert in your app
- API Reference - Detailed API documentation