@thepuskar/use-kit
v1.0.4
Published
React hooks and utility components with RSC-safe server/client entrypoints.
Readme
@thepuskar/use-kit
Typed React hooks and utility components with explicit RSC-safe and client entrypoints for Next.js App Router and other React 18+ apps.
Install
npm install @thepuskar/use-kitUsage
Component (server-safe)
import { Match, Switch } from "@thepuskar/use-kit";
export function Status({ user }: { user: { name: string } | null }) {
return (
<Switch fallback={<p>Please sign in</p>}>
<Match when={user}>{(u) => <p>Welcome, {u.name}</p>}</Match>
</Switch>
);
}Hook (client-only)
"use client";
import { useToggle } from "@thepuskar/use-kit/client";
export function ToggleButton() {
const [on, toggle] = useToggle(false);
return <button onClick={() => toggle()}>{on ? "ON" : "OFF"}</button>;
}RSC Guidance
@thepuskar/use-kitand@thepuskar/use-kit/serverare server-safe entrypoints.@thepuskar/use-kit/clientand@thepuskar/use-kit/hooksare client entrypoints.- In Next.js App Router, import hooks/client-only APIs only from
.../client(or.../hooks) inside files that have"use client".
Development
npm install
npm run build
npm run test
npm run lint
npm run format:checkCommunity
- Contributing: CONTRIBUTING.md
- Project Pipeline: PIPELINE.md
- Code of Conduct: CODE_OF_CONDUCT.md
- Support: SUPPORT.md
- Security: SECURITY.md
- License: LICENSE
