### Install ESLint and TSRX Plugin
Source: https://tsrx.dev/getting-started
Install ESLint and the TSRX ESLint plugin for linting .tsrx files.
```bash
pnpm install -D eslint @tsrx/eslint-plugin
```
--------------------------------
### Install Preact + Bun Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX Preact compiler, Bun plugin, and Preact using pnpm.
```bash
1 pnpm install @tsrx/preact @tsrx/bun-plugin-preact preact
```
--------------------------------
### Install React + Rspack Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX React compiler and Rspack plugin using pnpm.
```bash
1 pnpm install @tsrx/react @tsrx/rspack-plugin-react
```
--------------------------------
### Install React + Vite Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX React compiler and Vite plugin using pnpm.
```bash
1 pnpm install @tsrx/react @tsrx/vite-plugin-react
```
--------------------------------
### Install React + Bun Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX React compiler, Bun plugin, and React runtime using pnpm.
```bash
1 pnpm install @tsrx/react @tsrx/bun-plugin-react react react-dom
```
--------------------------------
### Install Solid + Vite Plugins
Source: https://tsrx.dev/getting-started
Install the TSRX Solid compiler, its Vite plugin, and the upstream vite-plugin-solid using pnpm.
```bash
1 pnpm install @tsrx/solid @tsrx/vite-plugin-solid vite-plugin-solid
```
--------------------------------
### Install Preact + Vite Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX Preact compiler and Vite plugin using pnpm.
```bash
1 pnpm install @tsrx/preact @tsrx/vite-plugin-preact
```
--------------------------------
### Install Preact + Rspack Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX Preact compiler and Rspack plugin using pnpm.
```bash
1 pnpm install @tsrx/preact @tsrx/rspack-plugin-preact
```
--------------------------------
### Install Vue Compiler and Bun Plugin
Source: https://tsrx.dev/getting-started
Install packages for Vue.js integration with Bun, including the Vue runtime and Vapor JSX plugin.
```bash
pnpm install @tsrx/vue @tsrx/bun-plugin-vue vue vue-jsx-vapor
```
--------------------------------
### Install TSRX with Ripple Target
Source: https://tsrx.dev/llms.txt
Installs the Ripple runtime and its Vite plugin for TSRX integration.
```bash
npm install ripple @ripple-ts/vite-plugin
```
--------------------------------
### Install React + Turbopack Plugin
Source: https://tsrx.dev/getting-started
Install the TSRX React compiler and Turbopack helper along with React and ReactDOM.
```bash
1 pnpm install @tsrx/react @tsrx/turbopack-plugin-react next react react-dom
```
--------------------------------
### Install Prettier and TSRX Plugin
Source: https://tsrx.dev/getting-started
Install Prettier and the TSRX Prettier plugin to enable formatting of .tsrx files.
```bash
pnpm install -D prettier @tsrx/prettier-plugin
```
--------------------------------
### Install Solid Compiler and Rspack Plugin
Source: https://tsrx.dev/getting-started
Install the necessary packages for SolidJS integration with Rspack. This enables compilation of .tsrx files for Solid.
```bash
pnpm install @tsrx/solid @tsrx/rspack-plugin-solid
```
--------------------------------
### Install Vue Compiler and Vite Plugin
Source: https://tsrx.dev/getting-started
Install packages for Vue.js integration with Vite, including the Vue runtime and Vapor JSX plugin.
```bash
pnpm install @tsrx/vue @tsrx/vite-plugin-vue vue vue-jsx-vapor
```
--------------------------------
### Install TSRX with Solid Target
Source: https://tsrx.dev/llms.txt
Installs the TSRX Solid target and a Vite plugin for integration. Rspack plugin is also available.
```bash
npm install @tsrx/solid
npm install -D @tsrx/vite-plugin-solid
```
--------------------------------
### Install Vue Compiler and Rspack Plugin
Source: https://tsrx.dev/getting-started
Install packages for Vue.js integration with Rspack, including the Vue runtime and Vapor JSX plugin.
```bash
pnpm install @tsrx/vue @tsrx/rspack-plugin-vue vue vue-jsx-vapor
```
--------------------------------
### Install TSRX with Preact Target
Source: https://tsrx.dev/llms.txt
Installs the TSRX Preact target and a Vite plugin for integration. Rspack and Bun plugin options are also available.
```bash
npm install @tsrx/preact
npm install -D @tsrx/vite-plugin-preact # Vite
```
--------------------------------
### Callback Ref Example in TSRX
Source: https://tsrx.dev/llms.txt
Demonstrates a direct callback ref on an input element, applicable across all TSRX targets.
```tsrx
// Callback ref — every target.
node?.focus()} />
```
--------------------------------
### Bun Setup for React Target
Source: https://tsrx.dev/llms.txt
Sets up the TSRX React Bun plugin for compiling .tsrx files to TSX within a Bun build process. Supports component-local CSS modules.
```typescript
// build.ts
import tsrxReact from '@tsrx/bun-plugin-react';
await Bun.build({
entrypoints: ['./src/App.tsrx'],
outdir: './dist',
target: 'browser',
plugins: [tsrxReact()],
});
```
--------------------------------
### Install TSRX with React Target
Source: https://tsrx.dev/llms.txt
Installs the TSRX React target and a Vite plugin for integration. Other bundler integrations like Rspack and Turbopack are also available.
```bash
npm install @tsrx/react
npm install -D @tsrx/vite-plugin-react # Vite
```
--------------------------------
### Install TSRX with Vue Target
Source: https://tsrx.dev/llms.txt
Installs the TSRX Vue target, Vue, and vue-jsx-vapor, along with a Vite plugin for integration. Bun plugin is also available.
```bash
npm install @tsrx/vue vue vue-jsx-vapor
npm install -D @tsrx/vite-plugin-vue
```
--------------------------------
### Turbopack Setup for React Target
Source: https://tsrx.dev/llms.txt
Configures the TSRX React Turbopack plugin for Next.js projects, enabling compilation of .tsrx files to TSX for React.
```typescript
// next.config.ts
import tsrxReactTurbopack from '@tsrx/turbopack-plugin-react';
export default tsrxReactTurbopack({
reactStrictMode: true,
});
```
--------------------------------
### Bun Setup for Vue with @tsrx/bun-plugin-vue
Source: https://tsrx.dev/llms.txt
Configure Bun to build Vue projects using the @tsrx/bun-plugin-vue. This plugin compiles .tsrx files to TSX, processes them with vue-jsx-vapor, and handles component-local styles.
```typescript
// build.ts
import tsrxVue from '@tsrx/bun-plugin-vue';
await Bun.build({
entrypoints: ['./src/App.tsrx'],
outdir: './dist',
target: 'browser',
plugins: [tsrxVue()],
});
```
--------------------------------
### Install TypeScript Plugin for TSRX
Source: https://tsrx.dev/getting-started
Install the TSRX TypeScript plugin to enable TypeScript language services for .tsrx files outside the VS Code extension.
```bash
pnpm install -D @tsrx/typescript-plugin
```
--------------------------------
### Bun Setup for Preact Target
Source: https://tsrx.dev/llms.txt
Configures the TSRX Preact Bun plugin for compiling .tsrx files to TSX with Preact's JSX runtime in a Bun build. Handles component-local CSS.
```typescript
// build.ts
import tsrxPreact from '@tsrx/bun-plugin-preact';
await Bun.build({
entrypoints: ['./src/App.tsrx'],
outdir: './dist',
target: 'browser',
plugins: [tsrxPreact()],
});
```
--------------------------------
### Rspack Setup for Solid Target
Source: https://tsrx.dev/llms.txt
Integrates the TSRX Solid plugin into Rspack for compiling .tsrx files to TSX with Solid JSX support. Defaults to hot module replacement enabled.
```javascript
// rspack.config.js
import { TsrxSolidRspackPlugin } from '@tsrx/rspack-plugin-solid';
export default {
plugins: [new TsrxSolidRspackPlugin()],
};
```
--------------------------------
### Rspack Setup for TSRX Preact Target
Source: https://tsrx.dev/llms.txt
Configures Rspack to use the TSRX Preact plugin, enabling compilation of `.tsrx` files to TSX and handling of CSS module imports.
```javascript
// rspack.config.js
import { TsrxPreactRspackPlugin } from '@tsrx/rspack-plugin-preact';
export default {
plugins: [new TsrxPreactRspackPlugin()],
};
```
--------------------------------
### Rspack Setup for TSRX React Target
Source: https://tsrx.dev/llms.txt
Configures Rspack to use the TSRX React plugin, which handles `.tsrx` compilation to TSX and CSS module imports.
```javascript
// rspack.config.js
import { TsrxReactRspackPlugin } from '@tsrx/rspack-plugin-react';
export default {
plugins: [new TsrxReactRspackPlugin()],
};
```
--------------------------------
### Rspack Setup for Vue Target
Source: https://tsrx.dev/llms.txt
Integrates the TSRX Vue plugin into Rspack for compiling .tsrx files to TSX with Vue JSX support and stripping remaining TypeScript syntax.
```javascript
// rspack.config.js
import { TsrxVueRspackPlugin } from '@tsrx/rspack-plugin-vue';
export default {
plugins: [new TsrxVueRspackPlugin()],
};
```
--------------------------------
### Nested Children Prop Example
Source: https://tsrx.dev/llms.txt
Shows how to pass nested JSX elements as children to a composite component. This works directly as JSX statements.
```tsrx
// Nested children — works as JSX statements
"Content goes here.""Title"
"Loading..."
5 break; 6 case 'success': 7"Done!"
8 break; 9 default: 10"Unknown status."
11 } 12 } ``` -------------------------------- ### Async Boundaries with Try/Pending/Catch Source: https://tsrx.dev/features Handle asynchronous operations and lazy-loaded components using `try`/`pending`/`catch`. The `pending` branch displays while data is loading, and `catch` handles errors. ```typescript 1 const UserProfile = lazy(() => import('./UserProfile.tsrx')); 2 3 export component App() { 4 try { 5"Loading..."
8 } catch (e) { 9"Something went wrong."
10 } 11 } ``` -------------------------------- ### Configure React + Turbopack Plugin Source: https://tsrx.dev/getting-started Wrap your Next.js config with the TSRX React Turbopack helper to register a Turbopack rule for .tsrx files. ```javascript 1 import tsrxReactTurbopack from '@tsrx/turbopack-plugin-react'; 2 3 export default tsrxReactTurbopack({ 4 reactStrictMode: true, 5 }); ``` -------------------------------- ### Configure Vite for Vue Source: https://tsrx.dev/getting-started Integrate tsrxVue and vueJsxVapor plugins into your Vite configuration. Ensure tsrxVue is listed first. ```javascript import { defineConfig } from 'vite'; import tsrxVue from '@tsrx/vite-plugin-vue'; import vueJsxVapor from 'vue-jsx-vapor/vite'; export default defineConfig({ plugins: [ tsrxVue(), vueJsxVapor({ macros: true, compiler: { runtimeModuleName: 'vue-jsx-vapor' }, }), ], }); ``` -------------------------------- ### Configure React + Vite Plugin Source: https://tsrx.dev/getting-started Add the TSRX React Vite plugin to your Vite configuration file. ```javascript 1 import { defineConfig } from 'vite'; 2 import tsrxReact from '@tsrx/vite-plugin-react'; 3 4 export default defineConfig({ 5 plugins: [tsrxReact()], 6 }); ``` -------------------------------- ### Configure Preact + Vite Plugin Source: https://tsrx.dev/getting-started Add the TSRX Preact Vite plugin to your Vite configuration. Optionally, configure the suspense source. ```javascript 1 import { defineConfig } from 'vite'; 2 import tsrxPreact from '@tsrx/vite-plugin-preact'; 3 4 export default defineConfig({ 5 plugins: [tsrxPreact()], 6 }); ``` -------------------------------- ### Configure Preact + Bun Plugin Source: https://tsrx.dev/getting-started Use the TSRX Preact Bun plugin in your Bun build script. It targets Preact's JSX runtime and supports overriding the default Suspense import. ```javascript 1 import tsrxPreact from '@tsrx/bun-plugin-preact'; 2 3 await Bun.build({ 4 entrypoints: ['./src/App.tsrx'], 5 outdir: './dist', 6 target: 'browser', 7 plugins: [tsrxPreact()], 8 }); ``` -------------------------------- ### Configure Preact + Rspack Plugin Source: https://tsrx.dev/getting-started Add the TSRX Preact Rspack plugin to your Rspack configuration. It chains SWC loader and handles CSS modules. ```javascript 1 import { TsrxPreactRspackPlugin } from '@tsrx/rspack-plugin-preact'; 2 3 export default { 4 plugins: [new TsrxPreactRspackPlugin()], 5 }; ``` -------------------------------- ### Add Typecheck Script to package.json Source: https://tsrx.dev/getting-started Add this script to your package.json to enable command-line type checking of .tsrx files using the tsrx-tsc binary. Run with `pnpm typecheck`. ```json { "scripts": { "typecheck": "tsrx-tsc --noEmit" } } ``` -------------------------------- ### Configure React + Rspack Plugin Source: https://tsrx.dev/getting-started Add the TSRX React Rspack plugin to your Rspack configuration. It uses SWC loader and handles CSS modules. ```javascript 1 import { TsrxReactRspackPlugin } from '@tsrx/rspack-plugin-react'; 2 3 export default { 4 plugins: [new TsrxReactRspackPlugin()], 5 }; ``` -------------------------------- ### React/Preact Ref Object with Callback Refs Source: https://tsrx.dev/llms.txt Combines a React/Preact `useRef` object with anonymous and named callback refs on a single input element. Requires importing `useRef`. ```tsrx // React/Preact ref object + anonymous and named callback refs. import { useRef } from 'react'; component SearchBox() { const inputRef = useRef"Please sign in."
return; }"Here is your dashboard."
} ``` -------------------------------- ### Configure Prettier for TSRX Source: https://tsrx.dev/getting-started Add the TSRX Prettier plugin to your .prettierrc configuration file. ```json { "plugins": ["@tsrx/prettier-plugin"] } ``` -------------------------------- ### TSRX Conditional Rendering with If/Else Statements Source: https://tsrx.dev/features Demonstrates conditional rendering directly within TSRX templates using standard `if`/`else if`/`else` statements. This avoids the need for ternaries or wrapper components. ```typescript 1 component StatusBadge({ status }: { status: string }) { 2Body
>} /> ``` -------------------------------- ### Lazy Array Destructuring with Signals in tsrx Source: https://tsrx.dev/llms.txt Illustrates lazy array destructuring using `&[ ... ]` with Solid's `createSignal`. This preserves per-access signal reactivity. ```tsrx let &[count, setCount] = createSignal(0);{count()}
``` -------------------------------- ### TSRX async boundaries with try/pending/catch Source: https://tsrx.dev/llms.txt Handle asynchronous operations and their loading/error states using 'try', 'pending', and 'catch'. This pattern is used for lazy-loaded components and suspended data fetching. ```tsrx const UserProfile = lazy(() => import('./UserProfile.tsrx')); export component App() { try {"Loading..."
} catch (e) {"Something went wrong."
} } ``` -------------------------------- ### TSRX DOM Refs: Using React useRef with Callbacks Source: https://tsrx.dev/features Shows how to combine a native ref object (like React's `useRef`) with anonymous and named callback refs on a single element. This allows for multiple ref attachments. ```typescript 1 import { useRef } from 'react'; 2 3 component SearchBox() { 4 // Use the target's native ref object when you want an object slot. 5 const inputRef = useRef"Something went wrong."
7{short_bio}
}"Welcome to TSRX."
} ``` -------------------------------- ### Add TSRX MCP via Claude Code CLI Source: https://tsrx.dev/getting-started Add the TSRX MCP server directly from the command line for Claude Code. This command registers the necessary configuration for the AI tool. ```bash claude mcp add tsrx -- npx -y @tsrx/mcp ``` -------------------------------- ### Generated React Code for FeatureCard Source: https://tsrx.dev/playground Shows the transpiled React output for the FeatureCard component, including JSX with class names and conditional rendering logic using ternary operators. Also includes the associated CSS. ```jsx const FeatureCard__static1 = ({'Loading output...'}
); export function FeatureCard({ title, items, ready, }: { title: string; items: string[]; ready: boolean; }) { return ("Please sign in."
4 return; 5 } 6 7"Here is your dashboard."
9 } ``` -------------------------------- ### TSRX Render Props: Using Function-Valued Props Source: https://tsrx.dev/features Illustrates render props in TSRX, which are function-valued props. They can be passed as `children` or a named prop like `render`. Wrap returned TSRX in `"Loading..."
break; case 'success':"Done!"
break; default:"Unknown status."
} } ``` -------------------------------- ### TSRX Submodule Declarations Source: https://tsrx.dev/specification Defines the syntax for submodule declarations and imports, aligning with TC39 module proposals. ```typescript SubmoduleDeclaration : module Identifier { ModuleItemListopt } ``` ```typescript SubmoduleImportDeclaration : import ImportClause from Identifier ; ``` -------------------------------- ### Prop Shorthands for Matching Props Source: https://tsrx.dev/features Utilize prop shorthands `{propName}` when the prop name matches the variable name, simplifying syntax from `propName={propName}` to `{propName}`. This applies to all attributes and event handlers. ```typescript 1 // Instead of repeating the name: 2 3 4 // Use the shorthand: 5 ``` -------------------------------- ### Bailing out of Template Rules with Inline Functions Source: https://tsrx.dev/llms.txt Use plain inline JavaScript/TypeScript functions for unconstrained logic like loops or imperative control flow within component bodies. Call these functions from event handlers or expressions. ```tsrx export component Counter() { let count = 0; // Plain JS — no template restrictions apply const increment = () => { if (count >= 10) { count = 0; } else { count += 1; } }; } ``` -------------------------------- ### TSRX try/catch for error boundaries Source: https://tsrx.dev/llms.txt Wrap component trees in 'try { } catch (e) { }' to render fallback UI when a child throws an error. The 'pending { }' clause handles async operations. ```tsrx component SafeProfile({ userId }: { userId: string }) { try {"Something went wrong."
"Content goes here."
5