# 설치

## 패키지 매니저로 설치하기

Wepin Widget Javascript SDK를 npm 패키지로 설치 가능합니다.&#x20;

{% hint style="info" %}
해당 패키지는 웹 환경에서만 사용 가능합니다. Android, iOS 하이브리드 앱(Webview)에서는 사용할 수 없습니다.&#x20;
{% endhint %}

터미널에서 아래와 같이 <mark style="color:blue;">`npm install`</mark> 명령어를 입력합니다.

```shell
npm install @wepin/widget-sdk
```

설치가 완료되면 package.json에서 아래와 "dependencies"에 추가된 것을 확인할 수 있습니다.

```json
{
  "name": "wepin-widget-test-app",
  "version": "1.0.0",
  "description": "Wepin Widge Test App"
  "main": "app.js",
  "author": "honggildong@test.wepin.io",
  "dependencies": {
    "@wepin/widget-sdk": "^1.0.0"
  }
}
```

설치가 완료되면 아래와 같이 앱 ID와 앱 키를 넣고 init함수를 호출하면 wepin을 사용할 준비가 완료됩니다.

<pre class="language-javascript"><code class="lang-javascript"><strong>// 1. 패키지 import
</strong><strong>import '@wepin/widget-sdk'
</strong><strong>const testAppKey = 'ak_test_ghq1D5s1sfG234sbnhdsw24mnovk313' // 테스트용 앱 키 
</strong>const testAppId = 'app_id_eg12sf3491azgs520' // 테스트용 앱 ID
// 2. 초기화
const Wepin = window?.Wepin
const wepin = await Wepin.init( 
  testAppId,
  testAppKey  
)
</code></pre>

## `<script>` 태그로 설치하기

위핀 위젯을 연동할 HTML 페이지에 Javascript 파일을 추가 합니다.&#x20;

스크립트 로드가 완료되면 전역 객체(window)에 <mark style="color:blue;">`Wepin`</mark>이 생성 되고, 이 객체를 이용해서 초기화를 진행할 수 있습니다.

```html
<head>
  <title>위핀 연결 하기<title>
  <!-- 1. 스크립트 추가 -->
  <script src="https://cdn.jsdelivr.net/npm/@wepin/widget-sdk@1.0.0/dist/wepin-widget-sdk.min.js" defer async></script>
</head>
<script>
  const testAppKey = 'ak_test_ghq1D5s1sfG234sbnhdsw24mnovk313' // 테스트용 앱 키 
  const testAppId = 'app_id_eg12sf3491azgs520' // 테스트용 앱 ID
  // 2. 초기화
  const wepin = await Wepin.init( 
    testAppId,
    testAppKey
  )
</script>
```


---

# 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.wepin.io/deprecated/web-javascript-sdk/sdk/installation.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.
