@octalen/react
v0.1.0
Published
React wrapper for the @octalen/sdk browser analytics client.
Maintainers
Readme
@octalen/react
React wrapper for the tiny @octalen/sdk browser client.
@octalen/react is separate so the core SDK can stay framework-free and keep its <1kb size target.
Install
npm install @octalen/sdk @octalen/reactNext.js App Router
import { Analytics } from "@octalen/react";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<Analytics siteId="site_xxx" />
{children}
</body>
</html>
);
}Proxy Mode
<Analytics siteId="site_xxx" endpoint="/api/octalen/event" />Forward that route to your Octalen collector:
export async function POST(request: Request) {
const body = await request.text();
return fetch("https://collector.octalen.com/e", {
method: "POST",
headers: { "Content-Type": "text/plain" },
body,
});
}Props
type AnalyticsProps = {
siteId: string;
endpoint?: string;
autoPageviews?: boolean;
captureOnLocalhost?: boolean;
debug?: boolean;
};