# bugstack for JavaScript & TypeScript

JavaScript · TypeScript

# bugstack for JavaScript & TypeScript

Auto-fix TypeError, null access, async/await failures, and import errors in Express and Next.js.

## What JS/TS Errors bugstack Fixes

-   **TypeError** — null/undefined property access (Cannot read properties of undefined)
-   **x.map is not a function** — calling array methods on non-array values
-   **Missing or wrong local imports** — incorrect relative paths, missing named exports
-   **Unhandled async failures** — missing await, unhandled promise rejection
-   **Next.js hydration mismatches** — server/client HTML mismatch errors
-   **Next.js route handler errors** — runtime failures in API routes and middleware

## Install the SDK

Add bugstack to your project with a single command:

```
npm install bugstack-sdk
```

Then initialize it in your entry point:

```
import { bugstack } from 'bugstack-sdk';

bugstack.init({
  apiKey: process.env.BUGSTACK_API_KEY,
});
```

## Example Fix

bugstack detects a TypeError caused by accessing a property on null and writes a surgical fix:

Before (broken)

```
export function getUserName(user) {
  return user.profile.name;
}

// Runtime error when user.profile is null:
// TypeError: Cannot read properties
//   of null (reading 'name')
```

After (fixed by bugstack)

```
export function getUserName(user) {
  if (!user?.profile) {
    return null;
  }
  return user.profile.name;
}
```

## Related Error Guides

-   [Fix TypeError: Cannot read properties of undefined in Next.js](/errors/typeerror-in-nextjs)
-   [Fix Unhandled Promise Rejection in Express](/errors/unhandled-promise-rejection-express)
-   [Fix TypeError with React useState](/errors/typeerror-react-usestate)
-   [Fix Hydration Mismatch in Next.js](/errors/hydration-mismatch-nextjs)
-   [Fix ReferenceError in Next.js](/errors/referenceerror-in-nextjs)
-   [Fix CORS Error in Express API](/errors/cors-error-express-api)

[Full installation guide with config reference →](/docs/installation/javascript)

## Stop fixing JavaScript errors manually

bugstack catches runtime errors in production, writes the fix, runs your CI, and opens a tested pull request — in under 2 minutes.

[Start Free](https://dashboard.bugstack.ai/login)

14-day free trial · No credit card required