
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
zsa-react-query
Advanced tools
`zsa-react-query` is a companion library for `zsa` that provides seamless integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview) for querying and mutating server actions from client components in Next.js applicatio
zsa-react-query is a companion library for zsa that provides seamless integration with React Query for querying and mutating server actions from client components in Next.js applications.
Install zsa-react-query and its peer dependencies using your preferred package manager:
npm i zsa-react-query @tanstack/react-query
Wrap your application with a React Query provider:
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
function ReactQueryProvider({ children }: React.PropsWithChildren) {
const [client] = useState(new QueryClient())
return <QueryClientProvider client={client}>{children}</QueryClientProvider>
}
export default ReactQueryProvider
Set up your hooks:
import { useInfiniteQuery, useMutation, useQuery } from "@tanstack/react-query"
import { setupServerActionHooks } from "zsa-react-query"
const {
useServerActionQuery,
useServerActionMutation,
useServerActionInfiniteQuery,
} = setupServerActionHooks({
hooks: {
useQuery: useQuery,
useMutation: useMutation,
useInfiniteQuery: useInfiniteQuery,
},
})
export {
useServerActionInfiniteQuery,
useServerActionMutation,
useServerActionQuery,
}
Query a server action:
import { useServerActionQuery } from "@/lib/hooks/server-action-hooks"
import { getRandomNumber } from "./actions"
export default function RandomNumberDisplay() {
const { isLoading, isRefetching, isSuccess, data } = useServerActionQuery(
getRandomNumber,
{
input: {
min: 0,
max: 100,
},
queryKey: ["getRandomNumber"],
}
)
// ...
}
Mutate a server action:
import { useServerActionMutation } from "@/lib/hooks/server-action-hooks"
import { updateEmail } from "./actions"
export default function UpdateEmailForm() {
const { mutate, isLoading } = useServerActionMutation(updateEmail)
const handleSubmit = (e) => {
e.preventDefault()
const newEmail = e.target.email.value
mutate({ newEmail })
}
// ...
}
For more detailed documentation and examples, please refer to the full documentation.
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
zsa-react-query is released under the MIT License.
FAQs
`zsa` is a library for building typesafe server actions in Next.js. It provides a simple, scalable developer experience with features like validated inputs/outputs, procedures (middleware) for passing context to server actions, and React Query integration
The npm package zsa-react-query receives a total of 627 weekly downloads. As such, zsa-react-query popularity was classified as not popular.
We found that zsa-react-query 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.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.