DEV Community

Cover image for πŸ€·β€β™€οΈ SeraJS is a lightweight, signal-based reactive JavaScript library
Nazmul Hossain
Nazmul Hossain

Posted on

πŸ€·β€β™€οΈ SeraJS is a lightweight, signal-based reactive JavaScript library

GitHub Link

πŸ“– Introduction

SeraJS is a lightweight, signal-based reactive JavaScript library for
building dynamic user interfaces.

At just 1.25KB gzipped and only 135 lines of code, it's a remarkably lightweight reactive UI library β€” offering powerful reactivity with minimal overhead.

⚑️ SeraJS focuses on minimalism and performance without sacrificing
developer experience.

Bundle Size Comparison (Minified + Gzipped)

Library Size (gzipped) Build Step Required Main Purpose Key Features
SeraJS 1.25kb Optional 😎 Reactive UI 135 lines of code, extremely lightweight
React ~40kb Yes UI components Virtual DOM, component-based architecture, JSX
Vue ~33kb Optional Progressive framework Reactive data binding, component system, single-file components
Solid.js ~7kb Yes Reactive UI No virtual DOM, compiled templates, fine-grained reactivity
Alpine.js ~7.1kb No Lightweight framework Minimal DOM manipulation, declarative syntax, works with existing HTML
Preact ~4kb Yes React alternative API compatible with React, smaller size, faster performance
htmx ~14kb No AJAX enhancements HTML attributes for AJAX, minimal JavaScript, server-side rendering friendly

βš™οΈ Core Concepts

πŸ”„ Signal-Based Reactivity

SeraJS uses a signal-based reactive system, a modern approach to state
management that enables efficient updates:

  • 🧠 Signals

    Self-contained reactive values that notify subscribers when they change.

  • πŸŒ€ Effects

    Functions that automatically re-execute when their dependencies (signals)

    change.

  • 🧭 Memo

    A memoization helper similar to React's useMemo, used to cache the result

    of a computation based on reactive dependencies to avoid unnecessary
    recalculations.

  • πŸ”¬ Fine-Grained Updates

    Only the specific DOM elements affected by state changes are updated,

    resulting in minimal re-rendering and high performance.

πŸ’‘ SeraJS is designed to be intuitive, fast, and easy to integrate into any
project β€” making it a perfect choice for modern frontend development.

Why SeraJS?

SeraJS brings together the best parts of libraries like React, Solid, and Lit β€” blending familiar patterns with a fresh, minimal approach.

At just 1.25KB gzipped and only 135 lines of code, this reactive UI library stays ultra-light while still delivering powerful reactivity.

Whether you want a build system or prefer a no-build workflow, SeraJS has you covered. It’s flexible enough to fit your dev style β€” use it how you want.

🌱 Sera.js Basic Example

A minimal example showing a Hello World message using Sera.js.

πŸ“„ App.jsx

import { h } from "serajs";

export default function App() {
  return (
    <h1>Hello world</h1>
  );
}
Enter fullscreen mode Exit fullscreen mode

No Build, No Dependencies

<!DOCTYPE html>
<html>
  <head>
    <title>Sera js 😎</title>
  </head>
  <body>
    <script type="module">
      import { h, setSignal, setEffect } from "//unpkg.com/serajs";

      function Hello() {
        const [count, setCount] = setSignal(0);

        setEffect(() => {
          console.log(count());
        });

        return h(
          "div",
          null,
          h("h1", null, "Hello World!"),
          h("p", { style: { color: "red" } }, "Do you Like Serajs?"),
          h("h1", null, () => `Count: ${count()}`),
          h(
            "button",
            { onclick: () => setCount(count() + 1) },
            "Increase Count"
          )
        );
      }

      const root = document.body;
      root.appendChild(Hello());
    </script>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Tiugo image

Fast, Lean, and Fully Extensible

CKEditor 5 is built for developers who value flexibility and speed. Pick the features that matter, drop the ones that don’t and enjoy a high-performance WYSIWYG that fits into your workflow

Start now

Top comments (0)

Neon image

Next.js applications: Set up a Neon project in seconds

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started β†’

πŸ‘‹ Kindness is contagious

Explore this insightful post in the vibrant DEV Community. Developers from all walks of life are invited to contribute and elevate our shared know-how.

A simple "thank you" could lift spiritsβ€”leave your kudos in the comments!

On DEV, passing on wisdom paves our way and unites us. Enjoyed this piece? A brief note of thanks to the writer goes a long way.

Okay