@ingrain/ingrain-react
v0.0.8
Published
Ingrain (ingrain.dev) React components for display user activity audit trails
Downloads
4
Readme
Ingrain React
Overview
This is the React UI Components package for Ingrain.
Ingrain is the fastest and easiest way to integrate activity audit trails in your app. Log a trail of user activities and employ our easy-to-integrate components to display these actions within your app's interface, offering your users a transparent view of their account activities.
Client JS SDK
If you only need the client side SDK, you can check out Ingrain Client SDK.
Getting Started
Prerequisites
- React v18+
- Node.js v18+
Installation
npm i @ingrain/ingrain-react
or with yarn
:
yarn add @ingrain/ingrain-react
Usage
Ingrain requires your application to be wrapped in the <IngrainProvider/>
context.
If using Create React App, set REACT_APP_INGRAIN_PUBLISHABLE_KEY
to your publishable key in your .env.local
file to make the environment variable accessible on process.env
and pass it as the publishableKey
prop.
You will also need to obtain and pass in your user's JWT.
import { render } from 'react-dom';
import { IngrainProvider, UserActivity, EntityActivity } from '@ingrain/ingrain-react';
const publishableKey = process.env.REACT_APP_INGRAIN_PUBLISHABLE_KEY;
const userJwt = getUserJWT(); // Define how you can obtain your user's JWT
render(
<IngrainProvider
theme={{ mode: 'light' }} // or set it to dark mode. You can also customize your colors here.
opts={{
publishableKey,
getUserJwtToken: () => {
return userJwt;
},
}}
>
<App />
</IngrainProvider>,
document.getElementById('root'),
);
function App() {
return (
<>
{/* Activity timeline based on user */}
<UserActivity userId={'user-id-here'}>
{/* Activity timeline based on entity e.g. access token changes */}
<EntityActivity entityId={'entity-id-here'}>
</>
);
}
Documentation
You can start from Introduction or jump straight to React UI Components
Contributing
We're open to all community contributions! If you'd like to contribute in any way, please read our contributing guidelines