# ReactJS SDK

## 1 . **Installation & Setup**

To start using **AllStak**, follow these steps:

#### **1. Install AllStak SDK**

Run the following command in your project directory:

```sh
npm install @techsea/allstak-reactjs
```

or with **yarn**:

```sh
yarn add @techsea/allstak-reactjs
```

## **2. Import & Initialize AllStak**

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

```tsx
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`**:

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

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

export default App;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.allstak.io/reactjs-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
