@uniora/react
v1.2.0
Published
React helpers for @uniora/core: <Can>/<Feature>/useCan/useFeature over a server-computed AuthorizationSnapshot. UX only, never a security boundary.
Maintainers
Readme
@uniora/react
Headless React helpers for UNIORA: <Can>, <Feature>, useCan and useFeature over an AuthorizationSnapshot that your server computes. The client never talks to your database.
npm install @uniora/core @uniora/react// server (Server Component, API route...)
import { computeAuthorizationSnapshot } from "@uniora/core";
const snapshot = await computeAuthorizationSnapshot(engine, storage.features, {
identity, organizationId, permissions: ["vehicles.create"], features: ["advanced_reports"],
});// client
import { Can, Feature, UnioraProvider } from "@uniora/react";
<UnioraProvider snapshot={snapshot}>
<Can permission="vehicles.create"><CreateVehicleButton /></Can>
<Feature feature="advanced_reports"><ReportsPanel /></Feature>
</UnioraProvider>These components are UX only. Hiding a button is never a substitute for authorizing the real operation on the server.
Documentation: Express, Next.js and React guide and the full index.
License: Apache-2.0.
