Subi Connect is a React component library that can be used to easily add UI with Subi's core business logic.
Basic integration instructions are provided below. Please visit our docs 📄 for a more in-depth setup guide.
npm install @subifinancial/subi-connect
npm install @tanstack/react-query @tanstack/react-table
Add the Subi Connect Provider
to your application. This must come after your
QueryClientProvider
and encompass all Subi Connect components. We will discuss
your connectionFn
below.
import { SubiConnectProvider } from '@subifinancial/subi-connect';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
const queryClient = new QueryClient();
function App() {
/**
* Your internal id reference to the company and their name.
* For example:
* - You have company A who uses your services.
* - You will provide their id along with their name as viewed in your database.
* - The name is used for sanity checking; we will not use this.
*/
const company = { referenceId: someCompanyId, name: 'Company A' };
const connectionFn = useCallback(
async () => await yourFnToGetSubiConnectAccessToken(company),
[someCompanyId],
);
return (
<QueryClientProvider client={queryClient}>
<SubiConnectProvider
connectionFn={connectionFn}
companyContext={company.referenceId}
>
...
</SubiConnectProvider>
</QueryClientProvider>
);
}
The connection function needs to speak to your backend to get the API key. This helps with security by not exposing your Subi Connect API Key to the frontend.
The core idea is to hit our
https://subiconnect-api.subi.au/subi-connect/authentication/company-access-token
endpoint to generate a company access token with your Subi Connect Account API
Key and company data. Each company using your service will have their own
generated access token.
npm install
npm run build-storybook
npm run storybook
- Ensure you select your
TARGET_ENV
withTARGET_ENV=local npm run ...
- View the README docs in
/demo
for more information