Skip to content

v1.0.0

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 12 Oct 13:22
· 13 commits to main since this release

React ReBAC Release v1.0.0 馃帀

Summary

We are excited to announce the initial release of React ReBAC! This lightweight library brings Relationship-Based Access Control (ReBAC) capabilities to React applications, allowing you to manage access control with ease and flexibility.

Features

  • ReBAC Context Provider: Easily integrate the RebacProvider at the root of your React app to set up access control.
  • Dynamic Access Management: Set user relationships with different entities and roles, and use hooks to manage access control dynamically.
  • Conditional Rendering Component: AuthorizedContent component enables content to be displayed conditionally based on user relationships and roles.
  • TypeScript Support: Full TypeScript support, ensuring better type safety and developer experience.
  • Flexible Hooks:
    • useAuthorization to verify user access to specific entities.
    • useUserEntities for retrieving user entities with ease.

Installation

Install with npm:

npm install react-rebac

Or with Yarn:

yarn add react-rebac

Usage

Import and wrap your application with RebacProvider, and use the AuthorizedContent component to conditionally render content.

import { RebacProvider, AuthorizedContent, useRebac } from 'react-rebac';

const App: React.FC = () => (
  <RebacProvider>
    <MainContent />
  </RebacProvider>
);

const MainContent: React.FC = () => (
  <AuthorizedContent entityId="orgA" entityType="Organization" relationship="Admin">
    <h3>Admin Content</h3>
  </AuthorizedContent>
);

export default App;

Feedback

We would love to hear your feedback! Please open an issue if you encounter any problems or have feature requests.

This release note is ready for a GitHub release and can be adjusted as new features or changes are added to the library.