Same Solid app. 2× faster server rendering.1

A build-time optimizer for SolidJS 2.0. It inlines your components, so the server and the browser run less code.

npm i -D solid-optimizer
  1. Your code
  2. 1Inline components
  3. 2Remove providers
  4. 3Fold constants
  5. Solid compiles it
Compiled by Solid · App.js9 lines

Solid compiles it to 1 template and 0 component calls, down from 2 and 3.

templates 2 → 1component calls 3 → 0
Context providers: solid-optimizer rewrites the JSX in 3 passes. Solid then compiles it to 1 templates and 0 component calls, down from 2 and 3.

Half the server render time

Two real apps, rendered with and without solid-optimizer. Lower is better.

Solid alonesolid-optimizer

renderToString

−50%
158.0 µs158.0 µs ±1.9 µsSolid alone
79.6 µs79.6 µs ±1.9 µssolid-optimizer

Hydration

−22%
6.67 ms6.67 ms ±210.0 µsSolid alone
5.17 ms5.17 ms ±210.0 µssolid-optimizer

Client render

−29%
447.1 µs447.1 µs ±7.4 µsSolid alone
315.7 µs315.7 µs ±7.4 µssolid-optimizer

Heap per app

−42%
427.1 kB427.1 kB ±161 BSolid alone
246.8 kB246.8 kB ±161 Bsolid-optimizer

Owners

−47%
16151615Solid alone
858858solid-optimizer

Computations

−40%
11021102Solid alone
660660solid-optimizer
Every measure
MeasureSolid alonesolid-optimizerChange
Timings
First client render, fresh page4.84 ms3.94 ms−19%
Client render, warm447.1 µs315.7 µs−29%
Dispose, warm36.8 µs25.3 µs−31%
Heap held by one mounted app427.1 kB246.8 kB−42%
Hydration, fresh page6.67 ms5.17 ms−22%
renderToString, warm158.0 µs79.6 µs−50%
Client render
Script, gzip18.9 kB17.6 kB−6%
Templates created1312−8%
Templates cloned191190−1%
Elements3173170%
Text nodes3233230%
Comment markers1601600%
Owners1615858−47%
Computations1102660−40%
Signals read41410%
Dependency edges887323−64%
Server render
HTML16.7 kB16.7 kB−0%
HTML, gzip1.6 kB1.6 kB−0%
Hydration keys (_hk)191190−1%
Comment markers404402−0%
Hydration
Script, gzip25.4 kB24.9 kB−2%
Nodes created25250%
Server nodes removed000%
Templates cloned000%

1 An issue tracker with 40 rows, data under <Loading>, and narrowing <Show> callbacks. 2026-11-07. Median of 15 runs on Apple M2, Chromium 156 and Node v26.12.1.

Less code in every build

Six small apps. Pick one to compare Solid’s output with and without it.

186templates−67%
140component calls−100%
196hydration keys−68%
3905 B2196 Bclient code, gzip−44%

Three components and a debug branch fold into the page that uses them.

Solid’s JSX transform alone5 templates3 component calls4 hydration keys14 hydration markers974 B client code, gzip
import { template as _$template } from '@solidjs/web';
import { getNextElement as _$getNextElement } from '@solidjs/web';
import { getNextMarker as _$getNextMarker } from '@solidjs/web';
import { insert as _$insert } from '@solidjs/web';
import { scope as _$scope } from '@solidjs/web';
import { createComponent as _$createComponent } from '@solidjs/web';
import { className as _$className } from '@solidjs/web';
import { effect as _$effect } from '@solidjs/web';
import { addEvent as _$addEvent } from '@solidjs/web';
import { delegateEvents as _$delegateEvents } from '@solidjs/web';
import { runHydrationEvents as _$runHydrationEvents } from '@solidjs/web';
var _tmpl$ = /* @__PURE__ */ _$template(`<span>`);
var _tmpl$2 = /* @__PURE__ */ _$template(
  `<button type=button><!$><!/><!$><!/>`,
);
var _tmpl$3 = /* @__PURE__ */ _$template(
  `<p class=counter><!$><!/>: <!$><!/> <!$><!/>`,
);
var _tmpl$4 = /* @__PURE__ */ _$template(
  `<main><h1>Hello</h1><!$><!/><!$><!/>`,
);
var _tmpl$5 = /* @__PURE__ */ _$template(`<pre>debug panel`);
import { Show, createSignal } from 'solid-js';
import type { JSX } from '@solidjs/web';
const DEBUG = false;
function Icon(props: { name: string }) {
  var _el$ = _$getNextElement(_tmpl$);
  _$effect(
    () => `icon icon-${props.name}`,
    (_v$, _$p) => {
      _$className(_el$, _v$, _$p);
    },
  );
  return _el$;
}
function Button(props: {
  icon: string;
  onClick: () => void;
  children: JSX.Element;
}) {
  var _el$2 = _$getNextElement(_tmpl$2);
  var _el$3 = _el$2.firstChild;
  var [_el$4, _el$5] = _$getNextMarker(_el$3.nextSibling);
  var _el$6 = _el$4.nextSibling;
  var [_el$7, _el$8] = _$getNextMarker(_el$6.nextSibling);
  _$addEvent(_el$2, 'click', props.onClick, true);
  _$insert(
    _el$2,
    _$createComponent(Icon, {
      get name() {
        return props.icon;
      },
    }),
    _el$4,
    _el$5,
  );
  _$insert(
    _el$2,
    _$scope(() => {
      return props.children;
    }),
    _el$7,
    _el$8,
  );
  _$runHydrationEvents();
  return _el$2;
}
function Counter(props: { label: string; start: number }) {
  const [count, setCount] = createSignal(props.start);
  var _el$9 = _$getNextElement(_tmpl$3);
  var _el$10 = _el$9.firstChild;
  var [_el$11, _el$12] = _$getNextMarker(_el$10.nextSibling);
  var _el$13 = _el$11.nextSibling;
  var _el$14 = _el$13.nextSibling;
  var [_el$15, _el$16] = _$getNextMarker(_el$14.nextSibling);
  var _el$17 = _el$15.nextSibling;
  var _el$18 = _el$17.nextSibling;
  var [_el$19, _el$20] = _$getNextMarker(_el$18.nextSibling);
  _$insert(
    _el$9,
    _$scope(() => {
      return props.label;
    }),
    _el$11,
    _el$12,
  );
  _$insert(
    _el$9,
    _$scope(() => {
      return count();
    }),
    _el$15,
    _el$16,
  );
  _$insert(
    _el$9,
    _$createComponent(Button, {
      icon: 'plus',
      onClick: () => setCount(count() + 1),
      children: 'Add',
    }),
    _el$19,
    _el$20,
  );
  return _el$9;
}
export function App() {
  var _el$21 = _$getNextElement(_tmpl$4);
  var _el$22 = _el$21.firstChild;
  var _el$23 = _el$22.nextSibling;
  var [_el$24, _el$25] = _$getNextMarker(_el$23.nextSibling);
  var _el$26 = _el$24.nextSibling;
  var [_el$27, _el$28] = _$getNextMarker(_el$26.nextSibling);
  _$insert(_el$21, DEBUG ? _$getNextElement(_tmpl$5) : void 0, _el$24, _el$25);
  _$insert(
    _el$21,
    _$createComponent(Counter, {
      label: 'Clicks',
      start: 0,
    }),
    _el$27,
    _el$28,
  );
  return _el$21;
}
_$delegateEvents(['click']);
solid-optimizer, then the JSX transform1 template1 hydration key2 hydration markers528 B client code, gzip
import { template as _$template } from '@solidjs/web';
import { getNextElement as _$getNextElement } from '@solidjs/web';
import { getNextMarker as _$getNextMarker } from '@solidjs/web';
import { insert as _$insert } from '@solidjs/web';
import { scope as _$scope } from '@solidjs/web';
import { delegateEvents as _$delegateEvents } from '@solidjs/web';
import { runHydrationEvents as _$runHydrationEvents } from '@solidjs/web';
var _tmpl$ = /* @__PURE__ */ _$template(
  `<main><h1>Hello</h1><p class=counter>Clicks: <!$><!/> <button type=button><span class="icon icon-plus"></span>Add`,
);
import { Show, createSignal } from 'solid-js';
import type { JSX } from '@solidjs/web';
const DEBUG = false;
export function App() {
  const [count$1, setCount$1] = /* @__PURE__ */ createSignal(0);
  var _el$ = _$getNextElement(_tmpl$);
  var _el$2 = _el$.firstChild;
  var _el$3 = _el$2.nextSibling;
  var _el$4 = _el$3.firstChild;
  var _el$5 = _el$4.nextSibling;
  var [_el$6, _el$7] = _$getNextMarker(_el$5.nextSibling);
  var _el$8 = _el$6.nextSibling;
  var _el$9 = _el$8.nextSibling;
  _$insert(
    _el$3,
    _$scope(() => {
      return count$1();
    }),
    _el$6,
    _el$7,
  );
  _el$9._$$click = () => setCount$1(count$1() + 1);
  _$runHydrationEvents();
  return _el$;
}
_$delegateEvents(['click']);
Open this example in the REPL

Each example is one module, compiled by @solidjs/compiler with and without solid-optimizer first, and rendered on the server with renderToString. Sizes are the client code before minification.

One import changes

It wraps @solidjs/vite-plugin, so SSR, server functions and HMR keep working.

// vite.config.ts
import { defineConfig } from 'vite';
import solid from 'solid-optimizer/vite';

export default defineConfig({
  // Replaces @solidjs/vite-plugin, with the same options.
  plugins: [solid()],
});
Set up the Vite plugin

Four passes, run until nothing changes

Each pass can expose work for the next.

01

Component inlining

A call becomes the component’s JSX, so it joins the parent’s template.

function Title(props) {
  return <h1 class="title">{props.label}</h1>;
}

<main><Title label="Hello" /></main>
<main>
  <h1 class="title">{'Hello'}</h1>
</main>
02

Context inlining

A provider whose readers are all visible is removed. Each read gets its value.

<Theme value="dark">
  <Label />
</Theme>

// Label: useContext(Theme)
<span class={'dark'}>label</span>
03

Memo inlining

A memo that always makes a new value and is read once becomes its computation.

const style = createMemo(() => ({
  color: color(),
}));
<p style={style()} />
<p style={{ color: color() }} />
04

Control flow folding

<Show>, <Switch>, <For> and <Dynamic> resolve when their props are constants.

const LINKS = [{ href: '/' }, { href: '/docs' }];
<For each={LINKS}>
  {(link) => <a href={link.href} />}
</For>
<a href={'/'} /><a href={'/docs'} />

Why not inline by hand?

You would trade readable components for speed. solid-optimizer keeps both.

FeatureSolid aloneBy handsolid-optimizer
Components join their parent’s templateNoYesYes
Your source keeps its componentsYesNoYes
Providers go when every reader is knownNoBy handYes
Constant branches foldWith optimizeBy handYes
Lists what it left aloneNoNoYes

Questions

What people ask before they add it.

Is it ready to use?

Version 1.0 is out for SolidJS 2.0, under the MIT license.

Does it work with Solid 1?

Use solid-optimizer@0. It gets fixes only.

Can it break hydration?

The Vite plugin compiles the server and client builds the same way, so both render the same tree. See Hydration.

Will my bundle grow?

A component only inlines where its copies are no larger than its calls. See Only where it is smaller.

Why did a component stay a component?

Turn on optimizer.report. It lists what stayed as written and why. See Report.

Try it on your components

The REPL runs both compilers in your browser.