
Research
/Security News
Trivy Under Attack Again: Widespread GitHub Actions Tag Compromise Exposes CI/CD Secrets
Attackers compromised Trivy GitHub Actions by force-updating tags to deliver malware, exposing CI/CD secrets across affected pipelines.
@solid-primitives/context
Advanced tools
Primitives simplifying the creation and use of SolidJS Context Providers.
npm install @solid-primitives/context
# or
yarn add @solid-primitives/context
createContextProviderCreate the Context Provider component and useContext function with types inferred from the factory function.
import { createContextProvider } from "@solid-primitives/context";
Given a factory function, createContextProvider creates a SolidJS Context and returns both a Provider component for setting the context, and a useContext helper for getting the context. The factory function gets called when the provider component gets executed; all props of the provider component get passed into the factory function, and what it returns will be available in the contexts for all the underlying components. The types of the provider props and context are inferred from the factory function.
const [CounterProvider, useCounter] = createContextProvider((props: { initial: number }) => {
const [count, setCount] = createSignal(props.initial);
const increment = () => setCount(count() + 1);
return { count, increment };
});
The provider component takes props declared as arguments of the factory functions.
// Provide the context
<CounterProvider initial={1}>
<App />
</CounterProvider>
The context will by default be T | undefined.
// get the context
const ctx = useCounter();
ctx?.count(); // => 1
The createContextProvider primitive takes a second, optional argument for providing context defaults for when the context wouldn't be provided higher in the component tree.
Providing a fallback also removes undefined from T | undefined return type of the useContext function.
const [CounterProvider, useCounter] = createContextProvider(
() => {
const [count, setCount] = createSignal(0);
const increment = () => setCount(count() + 1);
return { count, increment };
},
{
count: () => 0,
increment: () => {}
}
);
// then when using the context:
const { count } = useCounter();
Definite context types without defaults:
const useDefiniteCounter = () => useCounter()!;
function createContextProvider<T, P extends ContextProviderProps>(
factoryFn: (props: P) => T,
defaults: T
): [provider: ContextProvider<P>, useContext: () => T];
function createContextProvider<T, P extends ContextProviderProps>(
factoryFn: (props: P) => T
): [provider: ContextProvider<P>, useContext: () => T | undefined];
type ContextProviderProps = {
children?: JSX.Element;
} & Record<string, unknown>;
type ContextProvider<T extends ContextProviderProps> = (
props: { children: JSX.Element } & T
) => JSX.Element;
0.0.100
Initial release of the context package.
FAQs
Primitives simplifying or extending the SolidJS Context API
The npm package @solid-primitives/context receives a total of 5,132 weekly downloads. As such, @solid-primitives/context popularity was classified as popular.
We found that @solid-primitives/context demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.

Research
/Security News
Attackers compromised Trivy GitHub Actions by force-updating tags to deliver malware, exposing CI/CD secrets across affected pipelines.

Security News
ENISA’s new package manager advisory outlines the dependency security practices companies will need to demonstrate as the EU’s Cyber Resilience Act begins enforcing software supply chain requirements.

Research
/Security News
We identified over 20 additional malicious extensions, along with over 20 related sleeper extensions, some of which have already been weaponized.