🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@preact/signals-core

Package Overview
Dependencies
Maintainers
6
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/signals-core

Manage state with style in every framework

1.9.0
Source
npm
Version published
Weekly downloads
532K
-12.44%
Maintainers
6
Weekly downloads
 
Created

What is @preact/signals-core?

@preact/signals-core is a state management library designed for Preact applications. It provides reactive signals that can be used to manage and update state efficiently. The package is lightweight and focuses on providing a simple API for state management.

What are @preact/signals-core's main functionalities?

Creating Signals

Signals are reactive state containers. You can create a signal with an initial value and update it. The value of the signal can be accessed and modified using the `.value` property.

const { signal } = require('@preact/signals-core');
const count = signal(0);
console.log(count.value); // 0
count.value = 1;
console.log(count.value); // 1

Computed Values

Computed values are derived from other signals. They automatically update when the signals they depend on change.

const { signal, computed } = require('@preact/signals-core');
const count = signal(0);
const doubleCount = computed(() => count.value * 2);
console.log(doubleCount.value); // 0
count.value = 2;
console.log(doubleCount.value); // 4

Effects

Effects are functions that run whenever the signals they depend on change. They are useful for performing side effects in response to state changes.

const { signal, effect } = require('@preact/signals-core');
const count = signal(0);
effect(() => {
  console.log(`Count is now ${count.value}`);
});
count.value = 1; // Logs: Count is now 1

Other packages similar to @preact/signals-core

FAQs

Package last updated on 29 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts