โ† Back to Home

๐ŸŽฏ Basic Signal - Get Started in 30 Seconds

Learn how to create and update reactive state with just one hook. No Redux, no Context, no complexity.

๐Ÿ“š What You'll Learn

  • โœ“How to create a signal with useSignal(initialValue)
  • โœ“How to read the current value (it's just a variable!)
  • โœ“How to update the value with setCount(newValue)
0

๐Ÿ‘† Try the buttons below!

๐Ÿš€ How It Works (3 Simple Steps)

Step 1: Import the hook
import { useSignal } from 'signalforge/react';
Step 2: Create your signal
const [count, setCount] = useSignal(0); // Start at 0
Step 3: Use it like normal state!
{count} // Display the value
setCount(count + 1) // Update it

๐Ÿ’ป Complete Code Example

import { useSignal } from 'signalforge/react';

function Counter() {
  // Create a signal with initial value 0
  const [count, setCount] = useSignal(0);

  return (
    <div>
      <h1>Count: {count}</h1>
      
      {/* Update the signal */}
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
      
      <button onClick={() => setCount(0)}>
        Reset
      </button>
    </div>
  );
}

// That's it! Your component will automatically
// re-render when count changes. No useEffect,
// no useCallback, no useMemo needed!

๐Ÿ’ก Why SignalForge is Better

โŒ Traditional useState:
  • โ€ข Causes full component re-render
  • โ€ข Slow with many state updates
  • โ€ข Need useCallback/useMemo
  • โ€ข Complex prop drilling
โœ… SignalForge useSignal:
  • โ€ข Only re-renders what changed
  • โ€ข 33x faster with batching
  • โ€ข No extra optimization needed
  • โ€ข Global state built-in

๐ŸŽ“ Next Steps

Now that you understand basic signals, try these demos:

๐ŸŽฎ Interactive Playground (Click to expand)