Back to articles
Million.js Has a Free React Compiler — Here's How to Use It

Million.js Has a Free React Compiler — Here's How to Use It

via Dev.to ReactAlex Spinov

React re-renders entire component trees when state changes. Virtual DOM diffing is fast but not free. Million.js replaces React's Virtual DOM with direct DOM manipulation — up to 70% faster. What Is Million.js? Million.js is a drop-in compiler that optimizes React components. It analyzes your components at build time and replaces Virtual DOM operations with direct DOM updates. Quick Start npm install million // vite.config.ts import million from ' million/compiler ' ; import react from ' @vitejs/plugin-react ' ; export default { plugins : [ million . vite ({ auto : true }), // Auto-optimize all components react (), ], }; That's it. Your existing React app is now faster. No code changes needed. How It Works // Your code stays the same function Counter () { const [ count , setCount ] = useState ( 0 ); return ( < div > < p > Count: { count } </ p > < button onClick = { () => setCount ( count + 1 ) } > +1 </ button > </ div > ); } // Million.js compiler transforms it at build time: // Inst

Continue reading on Dev.to React

Opens in a new tab

Read Full Article
2 views

Related Articles