Open Ledger Quickstart
Everything you need to start integrating embedded accounting features into your application
Installation
Install the OpenLedger SDK for your framework of choice:
1npm install @openledger/accounting-react
Also install Tailwind CSS for styling components:
1npm install -D tailwindcss postcss autoprefixer
Quick Integration
1. Set up your provider/client
1234567891011121314151617181920212223import { OpenLedgerProvider } from "@openledger/accounting-react"; function App() { return ( <OpenLedgerProvider companyId="cm8jss2yn000112u83v8sa6mk" enterpriseId="cm8jss2v6000012u82knbymxx" enterpriseSecret="4ad14ae4f4fc487693287e0edc51c661" apiUrl="https://api-dev.openledger.com" environment="development" theme={{ primary: { hex: "#511320" }, // CRANBERRY accent: { hex: "#511320" }, // CRANBERRY background: { hex: "#FFFFFF" }, // WHITE text: { hex: "#511320" }, // CRANBERRY for text secondary: { hex: "#7D4955" }, // Lighter CRANBERRY shade negative: { hex: "#B22222" }, // A red that works with this palette }} > {/* Your app components */} </OpenLedgerProvider> ); }
2. Add components to your app
1234567891011121314151617181920import { OpenLedgerView, TransactionTable, DashboardBox } from "@openledger/accounting-react"; function MyComponent() { return ( <div> {/* Full accounting dashboard */} <OpenLedgerView /> {/* Or use individual components */} <TransactionTable /> <DashboardBox> {/* Custom content */} </DashboardBox> </div> ); }
3. Access data with hooks/methods
1234567891011121314151617181920212223242526import { useOpenLedgerContext, useTransactionContext, useAccountContext } from "@openledger/accounting-react"; function MyCustomComponent() { const { companyId, theme } = useOpenLedgerContext(); const { transactions, isLoading } = useTransactionContext(); const { accounts } = useAccountContext(); // Use the data in your component return ( <div> {isLoading ? ( <p>Loading transactions...</p> ) : ( <ul> {transactions.map(tx => ( <li key={tx.id}>{tx.description}</li> ))} </ul> )} </div> ); }
Using your API Keys
Your API keys are tied to your developer account. Current keys:Company ID: cm97t3pzd0015oymsbj40y3t1Enterprise ID (Developer ID): cm97t3pbg0014oyms16xi702rEnterprise Secret (API Key): 1083be70b90a4d8c959eedb5f7f74fd2For assistance with your API keys, contact api@openledger.com
Complete Example
Here's a complete React example showing how to set up the OpenLedger SDK and render the accounting dashboard:
index.tsx / main.tsx
12345678910111213141516171819202122232425262728import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import { OpenLedgerProvider } from "@openledger/accounting-react"; import App from "./App.tsx"; import "./index.css"; import "@openledger/accounting-react/dist/styles.css"; createRoot(document.getElementById("root")!).render( <StrictMode> <OpenLedgerProvider companyId="cm8jss2yn000112u83v8sa6mk" enterpriseId="cm8jss2v6000012u82knbymxx" enterpriseSecret="4ad14ae4f4fc487693287e0edc51c661" apiUrl="https://api-dev.openledger.com" environment="development" theme={{ primary: { hex: "#511320" }, // CRANBERRY accent: { hex: "#511320" }, // CRANBERRY background: { hex: "#FFFFFF" }, // WHITE text: { hex: "#511320" }, // CRANBERRY for text secondary: { hex: "#7D4955" }, // Lighter CRANBERRY shade negative: { hex: "#B22222" }, // A red that works with this palette }} > <App /> </OpenLedgerProvider> </StrictMode> );
App.tsx
1234567891011import { OpenLedgerView } from "@openledger/accounting-react"; function App() { return ( <div className="App"> <OpenLedgerView /> </div> ); } export default App;
tailwind.config.js
1234567891011121314151617181920212223242526272829/** @type {import('tailwindcss').Config} */ export default { content: [ "./index.html", "./src/**/*.{js,ts,jsx,tsx}", "./node_modules/@openledger/accounting-react/**/*.{js,ts,jsx,tsx}", ], theme: { extend: { colors: { cranberry: { DEFAULT: "#511320", 50: "#F9E9EC", 100: "#F3D3D9", 200: "#E6A7B3", 300: "#D97C8D", 400: "#CC5067", 500: "#BF2441", 600: "#991D34", 700: "#731627", 800: "#4C0E1A", 900: "#26070D", 950: "#130407", }, }, }, }, plugins: [], };
Interactive Demo
Experiment with the OpenLedger components in real-time. Edit the code below and see the changes rendered with Tailwind styling.
Code Editor
Note: In a production application, make sure to import the styles with:import "@openledger/accounting-react/dist/styles.css";
Live Preview
npm Package