Skip to main content
NostalgiaPHP
Home
About
  • Components
  • Blink
  • Fetch
  • Slider
  • REST API
BlogDoxSearchContact
Admin
  • Sitemap
  • Robots
GitHub
  1. Home
  2. Blog
  3. Don't Blink!
Sep 18, 2025

Don't Blink!

Blink: A Tiny Reactivity Layer

Sometimes you want a little bit of state and reactivity in your project — but you don’t want to bring in a whole framework, a bundler, or a giant runtime. That’s where Blink comes in.

Blink is only a few lines of JavaScript. You can copy-paste it into a file, or install it from npm or a cdn if you like. It gives you three exports: explicit, implicit, and fx.

let subscriber = null

export const explicit = value => {
  const subscriptions = new Set()

  return {
    get value() {
      if (subscriber) {
        subscriptions.add(subscriber)
      }
      return value
    },
    set value(newValue) {
      value = newValue
      subscriptions.forEach(fn => fn())
    },
  }
}

export const implicit = fn => {
  const _implicit = explicit()
  fx(() => {
    _implicit.value = fn()
  })
  return _implicit
}

export const fx = fn => {
  subscriber = fn
  fn()
  subscriber = null
}

How it works

  • explicit() creates a reactive value. Think of it as a simple signal — count = explicit(0) — that notifies subscribers when it changes.
  • fx() sets up a reactive effect. When you access a signal inside an fx function, that effect is re-run whenever the signal changes.
  • implicit() is just sugar. It creates a derived signal, automatically re-computing its value whenever its dependencies change.

That’s it. No virtual DOM, no compiler, no JSX. Just getters, setters, and a subscription set.


Example

Check out some demos:

  • Counter
  • Data Fetching

Why Blink?

Blink is not trying to be React or Svelte. It’s not even trying to be a framework. It’s just a tiny reactivity core that makes otherwise static sites feel alive.

That makes it a perfect companion for projects like Nostalgia, where you mostly want flat-file content, but you occasionally need a sprinkle of dynamic behavior without introducing complexity.


Further reading

  • Slank on npm (Blink’s package name)

Tagged:

  • js
  • slank
  • blink
  • reactivity

Explore

Recent Items

  • You Might Not Want to Use NostalgiaPHP
    Oct 8, 2025
  • Understanding the Styles
    Oct 5, 2025
  • Appear Animations
    Oct 2, 2025
  • Nosty CLI — Your New Best Friend
    Sep 28, 2025
  • Introducing the NostalgiaPHP REST API
    Sep 27, 2025

Tags

  • animation (1)
  • api (1)
  • blink (1)
  • css (1)
  • intersectionobserver (1)
  • js (1)
  • json (1)
  • nostalgia (2)
  • php (3)
  • reactivity (1)
  • rest (1)
  • retro (3)
  • simplicity (3)
  • slank (1)
© 2025 NostalgiaPHP. All rights reserved. ⬆ Back to Top