# GTKX > Build native GTK4 desktop applications with React and TypeScript GTKX is a framework for building native GTK4 desktop applications using React and TypeScript. It bridges React's component model with GTK4's native widget system via a custom React Reconciler and Rust-based FFI bindings. ## Key Features - **React Components**: Use React hooks, state, props, and component patterns - **Type Safety**: Full TypeScript support with auto-generated types from GTK4 introspection data - **Native Performance**: Direct FFI bindings to GTK4 via Rust and libffi (no Electron overhead) - **CSS-in-JS Styling**: Emotion-style `css` template literals for GTK widgets - **Testing Library**: Familiar `screen`, `userEvent`, and query APIs for testing components ## Documentation - Homepage: https://eugeniodepalo.github.io/gtkx/ - Introduction: https://eugeniodepalo.github.io/gtkx/docs/introduction - Getting Started: https://eugeniodepalo.github.io/gtkx/docs/getting-started - API Reference: https://eugeniodepalo.github.io/gtkx/docs/api/react - GitHub: https://github.com/eugeniodepalo/gtkx ## Architecture ``` React JSX -> @gtkx/react (Reconciler) -> @gtkx/ffi (TS wrappers) -> @gtkx/native (Rust) -> libffi -> GTK4 ``` 1. You write React components using JSX 2. The GTKX reconciler converts React elements into GTK widget nodes 3. TypeScript FFI bindings marshal calls to native GTK4 via Rust 4. GTK4 renders native widgets on your Linux desktop ## Packages | Package | Description | |---------|-------------| | @gtkx/react | React reconciler and JSX components | | @gtkx/ffi | TypeScript FFI bindings for GTK4, GLib, GIO, Gdk | | @gtkx/native | Rust native module providing the FFI bridge | | @gtkx/css | CSS-in-JS styling for GTK widgets (Emotion-style API) | | @gtkx/testing | Testing utilities with a Testing Library-style API | | @gtkx/gir | GObject Introspection parser for code generation | ## Quick Start ### Prerequisites - Node.js 20+ - GTK4 development libraries (`sudo dnf install gtk4-devel` on Fedora, `sudo apt install libgtk-4-dev` on Ubuntu) - Linux (GTK4 is Linux-native) ### Installation ```bash npm install @gtkx/react react npm install @gtkx/css # For styling (optional) npm install -D @gtkx/testing # For testing (optional) ``` ### Minimal Example ```tsx // index.tsx import { render } from "@gtkx/react"; import { App } from "./app.js"; render(, "org.example.MyApp"); ``` ```tsx // app.tsx import { ApplicationWindow, Box, Button, Label, quit } from "@gtkx/react"; import { Orientation } from "@gtkx/ffi/gtk"; import { useState } from "react"; export const App = () => { const [count, setCount] = useState(0); return (