ReactJS SDK

1 . Installation & Setup

To start using AllStak, follow these steps:

1. Install AllStak SDK

Run the following command in your project directory:

npm install @techsea/allstak-reactjs

or with yarn:

yarn add @techsea/allstak-reactjs

2. Import & Initialize AllStak

In your main React entry file (index.tsx or main.tsx), import and initialize AllStak:

import React from "react";
import ReactDOM from "react-dom/client";
import { AllStakErrorBoundary, initAllStak } from "@techsea/allstak-reactjs";
import App from "./App";

// AllStak Configuration
const config = {
  apiKey: "your_api_key",
  environment: "production",
};

// Initialize AllStak globally
initAllStak(config);

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
        {/* Wrap your entire application with the AllStak Error Boundary */}
        <AllStakErrorBoundary>
          <App />
        </AllStakErrorBoundary>
  </React.StrictMode>
);

3. Handling Errors in Components

To capture errors in specific components, wrap them with the AllStakErrorBoundary:

import { AllStakErrorBoundary } from "@techsea/allstak-reactjs";
import MyComponent from "./MyComponent";

function App() {
  return (
    <AllStakErrorBoundary>
      <MyComponent />
    </AllStakErrorBoundary>
  );
}

export default App;

Last updated