v1.1.0

Vue Project

Guide for installing Bitrix24 JS SDK in Vue applications.
We are still updating this page. Some data may be missing here — we will complete it shortly.

Add to a Vue project

Install the Bitrix24 JS SDK package

pnpm add @bitrix24/b24jssdk

Import

Import the library into your project:

import { LoggerFactory } from '@bitrix24/b24jssdk'

Init

To work with Bitrix24 from the application built into the Bitrix24 interface use the B24Frame object.

It is initialized on the client side using initializeB24Frame().

SomePage.vue
<script setup lang="ts">
import type { LoggerFactory, B24Frame } from '@bitrix24/b24jssdk'
import { onMounted, onUnmounted } from 'vue'

const $logger = LoggerFactory.createForBrowser('B24/jsSdk::vue', true)
let $b24: undefined | B24Frame

async function someFunction(): Promise<void> {
  if (!$b24) {
    return
  }
  // ...
}

onMounted(async () => {
  try {
    $b24 = await initializeB24Frame()
  } catch (error) {
    $logger.error('Some problems', { error })
  }
})

onUnmounted(() => {
  $b24?.destroy()
})
</script>