an island receiving signal

Welcome to the fresh logo: a sliced lemon dripping with juiceFresh, the next-gen web framework for Deno. This is a demo of using the new `@preact/signals` library in Fresh. It demonstrates how you can use signals to communicate across islands.

Not sure what signals are? Read the @preact/signals announcement blog post.

3

4

This counters uses a `useSignal` hook to create a signal that is local to the component. This means that each instance of this ` <Counter />` island has its own state.

Here, each slider is it's own island. However all of these islands share a single global `signal()`. This means that all of the sliders are synchronized with each other, sharing state across island boundaries. View the source code.

Cart

  • Your cart is empty.

Here we have two different types of islands that share a single common state `signal()` to store cart contents. The `<AddToCart />` island adds items to the cart, and the `<Cart />` island displays the contents and allows you to remove items from the cart.

You can use `@preact/signals` in your own Fresh project by adding these two entries to your `import_map.json`:

{
  "imports": {
    "@preact/signals": "https://esm.sh/*@preact/signals@1.0.0",
    "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.0"
  }
}

Source codeFresh DocsBuilt by @lcasdev