
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Features:
pnpm add solid-barn
or npm/yarn
Inspired by useSWR just for Solid
// useUser.tsx
import { useBarn } from "solid-barn";
function useUser({ id }: { id: () => string }) {
const { key, data, mutate, fetchState, isReady } = useBarn({
domain: "user",
isReady: async () => {
await sleep(700);
return true;
},
fetcher: async (filters) => {
await sleep(3000);
return { id: filters.id, name: "the user name" };
},
filters: () => ({ id: id() }),
});
return { key, data, mutate, fetchState, isReady };
}
// MyComp.tsx
import { createSignal, Match, Switch } from "solid-js";
import { sleep } from "~/utils/sleep";
import { useUser } from "~/hooks/useUser";
import { useSearchParams } from "@solidjs/router";
export function ShowUser() {
const [params, setParams] = useSearchParams();
const { data, fetchState, isReady, key, mutate } = useUser({ id: () => params.userId?.toString() ?? "" });
return (
<Switch>
<Match when={!isReady()}>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-emerald-600">not ready!</div>
</Match>
<Match when={!fetchState().initialized}>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-rose-500">initializing ...</div>
</Match>
<Match when={fetchState().isLoading}>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-amber-500">isLoading ...</div>
</Match>
<Match when={fetchState().error}>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-rose-950">{JSON.stringify({ error: fetchState().error })}</div>
</Match>
<Match when={data()}>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-yellow-100">{JSON.stringify(data())}</div>
</Match>
<Match when={true}>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-red-600">some unExpected happened!!!</div>
</Match>
</Switch>
);
}
In the case above, if params.userId has the same value, the filters and then key will be the same, so even though both components are creating the same resource with the same fetcher, only one request will be made to the server.
export function MutateUser() {
const [params, setParams] = useSearchParams();
const [value, setValue] = createSignal("");
const { key, mutate } = useUser({ id: () => params.userId?.toString() ?? "" });
return (
<div class="flex flex-col gap-4 w-full">
<Input value={value()} onInput={(e) => setValue(e.target.value)} type="text" />
<Button onClick={() => mutate("name", value())}>mutate value</Button>
<Button onClick={() => setParams?.({ x: value() })}>mutate filter</Button>
<div class="px-6 py-2 rounded-full flex items-center justify-center bg-indigo-400">{key()}</div>
</div>
);
}
FAQs
A State and data manager for solid js
We found that solid-barn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.