> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/nodejs.md).

# Node.js

{% hint style="success" %}
In Node.js, you can integrate the SDK using `@hackler/javascript-sdk`.

If you are using `@hackler/hackle-sdk`, you need to migrate to `@hackler/javascript-sdk`.
{% endhint %}

## Add SDK Dependency

[![](https://img.shields.io/npm/v/%40hackler%2Fjavascript-sdk)](https://www.npmjs.com/package/@hackler/javascript-sdk)

{% tabs %}
{% tab title="npm" %}

```shell
npm install --save @hackler/javascript-sdk
```

{% endtab %}

{% tab title="yarn" %}

```shell
yarn add @hackler/javascript-sdk
```

{% endtab %}
{% endtabs %}

## SDK Initialization

`hackleClient` is the class that provides methods for using SDK features.

To use the SDK, you need to initialize `hackleClient`.

#### Instantiation

Instantiate `hackleClient` by passing the SDK Key.\
`hackleClient` periodically synchronizes with the Hackle server as a background task to obtain the necessary information.

* You can find the SDK Key in [SDK Integration Info](https://dashboard.hackle.io/config/sdk-setting) located inside the Hackle Service Dashboard.

```javascript
const Hackle = require("@hackler/javascript-sdk");

// YOUR_SERVER_SDK_KEY 자리에 SDK 키를 넣습니다.
const hackleClient = Hackle.createInstance("YOUR_SERVER_SDK_KEY");
```

#### Initialization Complete

When the SDK is initialized, it fetches the necessary information from the Hackle server.

Initialization is performed asynchronously and you can receive the initialization completion callback via `onReady`.

{% hint style="warning" %}
If a user request arrives before the SDK is ready, **data may be lost.**
{% endhint %}

```javascript
hackleClient.onReady(() => {
  // SDK ready to use
  http.createServer((req, res) => {

  }).listen(3000)
});
```

## Shutdown

You must call the `close()` method when the application shuts down. This releases resources in use and sends any remaining events.

{% hint style="danger" %}
If the application shuts down without calling `close()`, **events may be lost.**
{% endhint %}

```javascript
process.on('SIGINT', function() {
  // kill signal
  hackleClient.close();
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.hackle.io/en/development-guide/nodejs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
