> For the complete documentation index, see [llms.txt](https://platform-business.gitbook.io/klat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform-business.gitbook.io/klat/javascript/getting-started.md). Agents can also search and read this documentation through its [MCP server](https://platform-business.gitbook.io/klat/~gitbook/mcp).

# Getting Started

## 0. 최소 지원 사양

* IE11
* Edge 12
* Firefox 29
* Chrome 33
* Safari 7.1

***

{% hint style="warning" %}
SPA (Vue.js, React) 또는 React Native 환경에서 FCM 푸시 알림을 처리하려면 [이 문서](https://docs.talkplus.io/javascript/push-notification-fcm)를 확인하세요.
{% endhint %}

## 1a. NPM 이용

```bash
npm install talkplus-sdk
```

## 1b. CDN 이용

```markup
<script src="https://asset.talkplus.io/npm/talkplus-0.5.9"></script>
```

## 1c. JS 라이브러리 파일 다운로드

{% file src="/files/PqihtvsXIeUKhPBHNQ5i" %}

## 2. Initialize

```javascript
const client = new TalkPlus.Client({appId: 'YOUR_APP_ID'});
```

## 3. Promise, Async/Await and Callback

JS SDK에서 제공하는 모든 함수는 Promise, Promise 기반의 async/await, 또는 callback 방식으로 호출할 수 있습니다.

```javascript
// Promise
this.loginAnonymous({
      userId: 'user-123',
      username: 'user-123',
      profileImageUrl: '',
    })
      .then((data) => console.log(data))
      .catch((err) => console.error(err));
      
// async/await
try {
    await client.loginAnonymous({
        userId: 'user-123',
        username: 'user-123',
        profileImageUrl: '',
    });
} catch (err) {
}


// callback
client.loginAnonymous({
    userId: 'user-123', 
    username: 'user-123',
}, function (err, data) {
    console.error(err);
    console.log(data);
});
```

## 4. Login/Logout 프로세스

1. TalkPlus는 매 실행시마다 login 함수(loginAnonymous 혹은 loginWithToken)의 호출이 필요합니다.
2. 웹 푸시 알림(web push notification)기능은 지원하지 않으나, 클라이언트를 통한 실시간 이벤트 기능이 지원됩니다.
3. 쿠키 그리고 로컬 또는 세션 스토리지를 사용하고 있지 않기 때문에 브라우저나 탭을 닫을 시 세션이 종료됩니다.

## 5. Error

에러 발생 시, 다음과 같은 형식의 error response를 제공합니다.

```javascript
{
  "error": true,
  "code": "1006",
  "message": "Unauthorized"
}
```
