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

eden-react-query

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eden-react-query

Wrapper for Eylsia's Eden to use React Query

0.0.20
latest
npm
Version published
Maintainers
0
Created
Source

Eden React Query

Wrapper for Eylsia's Eden to use React Query

Installation

npm i eden-react-query

Usage

import type { App } from "./path-to-your-elysia";
import { treaty } from "@elysiajs/eden";
import { createClient } from "eden-react-query";

const eden = treaty<App>("http://localhost:3000");

const hooks = createClient(eden);
"use client";

import { hooks } from "@/utils/eden";

export default function HomeClient() {
    const countQuery = hooks.count.get.useQuery();
    const countMutation = hooks.count.post.useMutation({
        onSuccess: () => {
            countQuery.refetch();
        },
    });
    return (
        <main>
            <button onClick={() => countMutation.mutate()}>Click me</button>{" "}
            {countQuery.data ? countQuery.data.count : "Loading..."}
        </main>
    );
}
import HomeClient from "./page.client";
import { HydrationBoundary } from "@tanstack/react-query";
import { createUtils } from "eden-react-query/server";
import { eden } from "@/utils/eden";

export default async function Home() {
    const utils = createUtils(eden);
    await utils.count.get.prefetch();
    return (
        <HydrationBoundary state={utils.dehydrate()}>
            <HomeClient />
        </HydrationBoundary>
    );
}

Refer to Elysia and React Query documentation for more information.

FAQs

Package last updated on 29 Aug 2024

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