SolidJS bindings for Lens API framework
npm install @sylphx/lens-solidSolidJS primitives for the Lens API framework.
``bash`
bun add @sylphx/lens-solid @sylphx/lens-client
`typescript
// lib/client.ts
import { createClient } from "@sylphx/lens-solid";
import { http } from "@sylphx/lens-client";
import type { AppRouter } from "@/server/router";
export const client = createClient
transport: http({ url: "/api/lens" }),
});
`
`tsx
import { client } from "@/lib/client";
import { Show } from "solid-js";
function UserProfile(props: { id: string }) {
const { data, loading, error, refetch } = client.user.get({
input: { id: props.id },
select: { name: true, email: true },
});
return (
$3
`tsx
import { client } from "@/lib/client";function CreateUser() {
const { mutate, loading, error, data, reset } = client.user.create({
onSuccess: (data) => console.log("Created:", data),
onError: (error) => console.error("Failed:", error),
});
const handleSubmit = async () => {
await mutate({ input: { name: "New User" } });
};
return (
);
}
`$3
`typescript
// Use .fetch() for promise-based calls
const user = await client.user.get.fetch({ input: { id } });
``MIT
---
Built with @sylphx/lens-client.
Powered by Sylphx