
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@wundergraph/swr
Advanced tools
This package provides a type-safe integration of SWR with WunderGraph. SWR is a React Hooks library for data fetching. With just one hook, you can significantly simplify the data fetching logic in your project. And it also covered in all aspects of speed, correctness, and stability to help you build better experiences.
Warning: Only works with WunderGraph.
npm install @wundergraph/swr swr@2.0.0
Before you can use the hooks, you need to modify your code generation to include the base typescript client.
// wundergraph.config.ts
configureWunderGraphApplication({
// ... omitted for brevity
codeGenerators: [
{
templates: [templates.typescript.client],
// the location where you want to generate the client
path: '../src/components/generated',
},
],
});
Second, run wunderctl generate to generate the code.
Now you can use the hooks.
import { createHooks } from '@wundergraph/swr';
import { createClient, Operations } from './components/generated/client';
const { useQuery, useMutation, useSubscription, useUser, useFileUpload, useAuth } = createHooks<Operations>(
createClient({ baseURL: 'https://your-wundernode.com', extraHeaders: {}, customFetch: undefined })
);
export const Home: React.FC<{ city: string }> = ({ city }) => {
const { error, data, isValidating } = useQuery({
operationName: 'Weather',
input: { forCity: city },
liveQuery: true,
});
const { data: subData, error: subError } = useSubscription({
enabled: true,
operationName: 'Weather',
input: {
forCity: 'Berlin',
},
});
const { trigger } = useMutation({
operationName: 'SetName',
});
trigger({ name });
const { data, error } = useUser();
const { upload, data, error } = useFileUpload();
const { login, logout } = useAuth();
};
You can use all available options from SWR with the hooks.
Due to the fact that we use the operationName + variables as key, you can't use the key option as usual.
In order to use conditional-fetching you can use the enabled option.
You can configure the hooks globally by using the SWRConfig context.
In case the context configuration isn't working, it's likely due to multiple versions of SWR being installed.
To resolve this you can import SWRConfig directly from @wundergraph/swr to make sure the same instance is used.
import { SWRConfig, useSWRConfig } from '@wundergraph/swr';
FAQs
WunderGraph SWR Integration
The npm package @wundergraph/swr receives a total of 270 weekly downloads. As such, @wundergraph/swr popularity was classified as not popular.
We found that @wundergraph/swr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.