React Quickstart
Permission gates and auth state in the scaffolded project's React frontend.
There is no separate @nebutra/react client package — apps/web (the scaffolded Next.js 16 App
Router project) is your React app. This page covers the pieces it ships with.
Gate UI with permission checks
@nebutra/permissions/react wraps CASL as React bindings:
import { Can } from "@nebutra/permissions/react";
export function DeleteButton({ projectId }: { projectId: string }) {
return (
<Can action="delete" resource="Project">
<button type="button" onClick={() => handleDelete(projectId)}>
Delete Project
</button>
</Can>
);
}<Can> renders nothing if the current user lacks the required scope. For an imperative check
inside a component, use the usePermission hook:
import { usePermission } from "@nebutra/permissions/react";
const canDelete = usePermission("delete", "Project", project);Both read from a <PermissionProvider> that wraps your app — already wired in the scaffold's root
layout.
Auth state
Session state comes from Better Auth's own React client (authClient from your project's
lib/auth-client.ts, generated by createAuthClient from better-auth/react), not a Nebutra SDK:
import { authClient } from "@/lib/auth-client";
export function UserMenu() {
const { data: session, isPending } = authClient.useSession();
if (isPending) return <Skeleton />;
if (!session) return <SignInButton />;
return <p>{session.user.name}</p>;
}Related
How is this guide?
Last updated on