rapid-test/app/page.tsx

24 lines
603 B
TypeScript

import { Welcome, createBoltClient } from "@rapid-web/react";
import { routes, Handlers } from "../pages/api/bindings";
const bolt = createBoltClient<Handlers, typeof routes>(routes, {
transport: "http://localhost:8080",
});
export default async function Home() {
const { data: title } = await bolt("hello").get(routes.hello);
const { data: message } = await bolt("echo").post(
routes.echo,
"Hello from the client!"
);
return (
<main>
<Welcome>
<p className="mt-4">{title}</p>
<span>The server replied: {message}</span>
</Welcome>
</main>
);
}