FreeMIT LicenseFeatured

Lightfall — Crypto & Web3 Hero Section for React with WebGL Background

A crypto and Web3 hero section for React over a hand-written WebGL light background: neon lanes fall into an order book, a live price ticker pulses the light on every move, and blocks settle like a heartbeat. Six palettes, light and dark themes.

by UpFork, built by Ramin ValadanComponentUpdated 26 Oct 2026

Read how it was madeBehind the build8 lessons
Watch0
Preview of Lightfall — Crypto & Web3 Hero Section for React with WebGL Background

Code

29 files · 1 package · 12 assets

/**
 * EXAMPLE ADAPTER — not used by the component, which makes no network calls of its own. Read it, adapt it, and check
 * your data provider's documentation and terms before you use a feed in production.
 *
 * Many exchanges publish a public "24h mini-ticker" websocket stream: every second or so, an array of objects like
 *
 *   { "e": "24hrMiniTicker", "s": "BTCUSDT", "c": "98420.50", "o": "96104.10", "h": "…", "l": "…", "v": "…" }
 *
 * (c = last price, o = price 24 hours ago). This turns such a stream into what <LightfallHero ticker={…}> reads:
 * an AsyncIterable<MarketTick[]>, at most one snapshot per `throttleMs`, reconnecting with back-off if the socket drops.
 *
 *   const feed = useMemo(() => createMiniTickerAdapter({
 *     url: "wss://<your provider>/<mini-ticker stream>",
 *     symbols: { BTCUSDT: "BTC", ETHUSDT: "ETH", SOLUSDT: "SOL" },
 *   }), []);
 */
import type { MarketTick } from "../types";

export type MiniTicker = { s: string; c: string; o: string };

export type MiniTickerAdapterOptions = {
  url: string;
  /** Provider symbol → the label to show, e.g. { BTCUSDT: "BTC" }. Only these are kept, in this order. */
  symbols: Record<string, string>;
  names?: Record<string, string>;
  throttleMs?: number;
  /** Turns one websocket message into mini-tickers. Default: JSON, an array or a single object (or { data: … }). */
  parse?: (data: string) => MiniTicker[];
};

const defaultParse = (data: string): MiniTicker[] => {
  const json = JSON.parse(data);
  const body = json && typeof json === "object" && "data" in json ? json.data : json;
  return Array.isArray(body) ? body : [body];
};

export function createMiniTickerAdapter({ url, symbols, names = {}, throttleMs = 1000, parse = defaultParse }: MiniTickerAdapterOptions): AsyncIterable<MarketTick[]> {
  const order = Object.keys(symbols);
  return {
    // One socket per iterator: each mount gets its own, and return() closes it.
    [Symbol.asyncIterator]() {
      const latest = new Map<string, MarketTick>();
      const history = new Map<string, number[]>();
      let ws: WebSocket | null = null;
      let closed = false;
      let dirty = false;
      let last = 0;
      let retry = 500;
      let waiting: ((r: IteratorResult<MarketTick[]>) => void) | null = null;
      let timer: ReturnType<typeof setTimeout> | undefined;

      const snapshot = () => order.flatMap((k) => (latest.has(k) ? [latest.get(k)!] : []));
      const flush = () => {
        if (!waiting || !dirty) return;
        const wait = last + throttleMs - Date.now();
        if (wait > 0) {
          clearTimeout(timer);
          timer = setTimeout(flush, wait);
          return;
        }
        dirty = false;
        last = Date.now();
        const resolve = waiting;
        waiting = null;
        resolve({ done: false, value: snapshot() });
      };

      const connect = () => {
        if (closed) return;
        ws = new WebSocket(url);
        ws.onopen = () => (retry = 500);
        ws.onmessage = (e) => {
          let list: MiniTicker[];
          try {
            list = parse(String(e.data));
          } catch {
            return;
          }
          for (const t of list) {
            const label = symbols[t.s];
            const price = Number(t.c);
            const open = Number(t.o);
            if (!label || !Number.isFinite(price)) continue;
            const h = [...(history.get(t.s) ?? []), price].slice(-24);
            history.set(t.s, h);
            latest.set(t.s, { symbol: label, name: names[t.s], price, change24h: open ? ((price - open) / open) * 100 : 0, sparkline: h });
            dirty = true;
          }
          flush();
        };
        ws.onclose = () => {
          if (closed) return;
          setTimeout(connect, retry);
          retry = Math.min(retry * 2, 15000);
        };
      };
      connect();

      return {
        next() {
          if (closed) return Promise.resolve({ done: true, value: undefined });
          return new Promise<IteratorResult<MarketTick[]>>((resolve) => {
            waiting = resolve;
            flush();
          });
        },
        return() {
          closed = true;
          clearTimeout(timer);
          ws?.close();
          waiting?.({ done: true, value: undefined });
          waiting = null;
          return Promise.resolve({ done: true, value: undefined });
        },
      };
    },
  };
}
29 files12 assets1 package

From the workbench

Written about Lightfall — Crypto & Web3 Hero Section for React with WebGL Background

By the developer who built it: how it works, with its real code and live preview in the text, and the lessons learned along the way.

About

Lightfall is a hero for an exchange or a Web3 product whose background means something. A hand-written WebGL2 shader pours lanes of neon light down a wall, bends them through a soft cove at the horizon and races them toward you across a floor: order flow falling into the book, settling, and leaving as finality. On top sits a complete hero, and a live market ticker whose price moves pulse the light.

What it does

  • Price moves, and the light answers. Every price change in the ticker drops a burst of light down that pair's own lane, rippling the floor where it lands. Call pulse() from your trade feed and the light is your market.
  • A block, every heartbeat. Every few seconds the lanes draw in and speed up, a fine bar of light crosses the horizon, a ring sweeps the floor, and the block counter above the headline flips its digits. Subtle by design.
  • A product-grade hero. Eyebrow with a live counter, a headline whose accent words take the palette's gradient, CTAs with a light sweep, stats that count up, a trust row, and a quiet hash readout.
  • A real market ticker. An endless marquee with digit-flip prices, red and green flashes and inline sparklines; it pauses on hover, on focus and with its own button. Feed it an array, a stream (a websocket adapter example is included) or a fetcher; a realistic mock market comes with it.
  • Six palettes. Tidewater, Ember, Aurora, Orchid, Glacier and Ledger (a bank's idea of neon), crossfaded in OKLab together with the headline, sparklines and focus rings. Bring your own from four colours and an accent.
  • Light, dark and auto. The light theme draws the same lanes as ink on paper; auto follows your site's .dark class or the system.
  • It moves with you. The pointer moves the camera across three parallax depths and carries a faint lamp; a click drops a pulse; scrolling away raises the horizon, speeds the floor and fades the copy. Phones get a tap-to-cycle palette chip and opt-in tilt.

Built to ship

Raw WebGL2 and GLSL, no 3D library, rendered in a Web Worker so your page's main thread never waits on the GPU: 21.8 kB gzipped with its shaders. Our demo scores 98+ for performance and 100 for accessibility, best practices and SEO in Lighthouse (desktop), with zero layout shift. Zero React renders per frame. Resolution adapts to keep 60 fps, the loop sleeps off screen, low battery and reduced data lower the effects, reduced motion turns movement into a slow drift, and without WebGL a baked poster takes its place. Text keeps a 4.5:1 contrast against the brightest light that passes behind it, the palette picker is a keyboard listbox, and the ticker has a screen-reader summary.

What's included

  • The LightfallHero component in TypeScript, with its own stylesheet (no Tailwind needed)
  • LightfallCanvas (the shader alone, for any section), MarketTicker, PalettePicker, useLightfall
  • A mock market stream and an example websocket adapter
  • Four demos: the exchange, a chain launch, daylight (light theme) and the plain background mode
  • Twelve no-WebGL posters (six palettes, dark and light)

Stack and requirements

  • React 18 or 19, TypeScript
  • motion is the only dependency
  • Works in the Next.js App Router and in Vite; WebGL2 (every current browser), with a poster fallback

Reviews and bugs

0 reviews · 0 bugs

Ship it0With fixes0Skip0· 0 reviews

0 bugs0 open0 fixed

Members who have it review it and report its bugs. Sign in

No reviews or bugs yet.

Manual installation

Without the CLI

  1. 01

    Install the packages

    npm install motion
  2. 02

    Copy the files into your project

    • components/lightfall-hero/adapters/exampleWebsocketAdapter.ts
    • components/lightfall-hero/adapters/mockTickerStream.ts
    • components/lightfall-hero/FlipText.tsx
    • components/lightfall-hero/format.ts
    • components/lightfall-hero/gl/engine.ts
    • components/lightfall-hero/gl/lanes.ts
    • components/lightfall-hero/gl/lightfall.worker.ts
    • components/lightfall-hero/gl/palettes.ts
    • components/lightfall-hero/gl/proxy.ts
    • components/lightfall-hero/gl/renderer.ts
    • components/lightfall-hero/gl/shaders.annotated.ts
    • components/lightfall-hero/gl/shaders.ts
    • components/lightfall-hero/gl/uniforms.ts
    • components/lightfall-hero/HashTicker.tsx
    • components/lightfall-hero/hooks/useAdaptiveQuality.ts
    • components/lightfall-hero/hooks/useLightfall.ts
    • components/lightfall-hero/hooks/useLowPower.ts
    • components/lightfall-hero/hooks/usePointerSpring.ts
    • components/lightfall-hero/hooks/useReducedMotion.ts
    • components/lightfall-hero/hooks/useScrollReact.ts
    • components/lightfall-hero/hooks/useVisibilityPause.ts
    • components/lightfall-hero/index.ts
    • components/lightfall-hero/LightfallCanvas.tsx
    • components/lightfall-hero/LightfallHero.tsx
    • components/lightfall-hero/MarketTicker.tsx
    • components/lightfall-hero/PalettePicker.tsx
    • components/lightfall-hero/StatCounter.tsx
    • components/lightfall-hero/styles.css
    • components/lightfall-hero/types.ts

    The paths follow the shadcn/ui layout, with @/ as your project’s import alias.

  3. 03

    Its pictures load from UpFork

    The code above points at UpFork’s copies (414 KB), so there’s nothing to copy. To host them yourself, use Download source: its ZIP has the files where the code expects them, and a README on the switch.

Before you buy

Everything you need to know

How this component gets from the preview into your project, and what buyers ask most.

How to use it

From the preview to your project

  1. 01

    Try it in the preview

    Switch between light and dark, and resize it to phone and tablet widths, before you decide.

  2. 02

    Get it

    Free products are yours with a free account. Paid ones settle in USDT on TRON, sent straight to the wallet on your order.

  3. 03

    Install it

    Components go into your project with one shadcn command, dependencies included. Everything else downloads with a checksum.

  4. 04

    Make it yours

    It's your code now: rename it, restyle it and wire in your real data.

  5. 05

    Or hand it to your AI

    Copy the prompt and let your coding assistant place it in your project, following your conventions.

Building with an AI assistant?

Copy a ready-made prompt with the code, its dependencies and a demo, and your assistant can put it in place for you.

Copy AI prompt

Selling your own work?

Get approved once, then publish components, templates and mobile components, paid in USDT straight to your own wallet.