Skip to main content

Guide for JavaScript

Using our JavaScript SDK, you can implement the haptic into your JS/TS project. Type system for TypeScipt, and ESM are also supported.

  1. Install package
  2. Set Up Haptic Environment

Requirements

  • Node.js (Latest LTS version is recommended)
  • OS: Windows 10/11 (x64)
  • bHaptics Player installed and running
  • Deployed haptic application corresponding to your project
    • App ID and API Key of the haptic app
About haptic application

You can create and manage haptic apps in Developer Portal, a web-based tool.

If you're unfamiliar with haptic apps or haven't created one yet, please follow the Portal guide before proceeding.

Before linking a haptic app to your game project, make sure the haptic app meets the following requirements:

  • At least one haptic event must be created.
  • API Key must be generated.
    • There is no API Key by default. To generate one, go to the "API Key" tab and click "New" button.
  • Haptic app must be deployed
    • If you see "Deploy Now" button in the upper right corner, click it to deploy your haptic app. Otherwise, if you can see "Up to date", it means that the latest haptic app has already been deployed.

Also, link process requires App ID and API Key. Go to the "Settings" tab, and check the App ID and API Key.

Check app ID, API key at the settings tab in Portal

Installation

npm install tact-js

Import Packages

import Tact from "tact-js";

Exclude for Optimizing

If you are using Vite, add the following to your Vite Configuration file:

vite.config.js
export default defineConfig({
// ...
optimizeDeps: {
exclude: ['tact-js'],
},
// ...
});

Set Up Haptic Environment

Before using any haptic-related functions, you need to link the haptic app to your project, and initialize the haptic environment.

To do this, you need App ID and API Key of your haptic app. You can get them from the bHaptics Developer Portal.

Initialize

  • Replace "your_app_id" and "your_api_key" with your App ID and API Key.
  • Before you launch the JavaScript project, ensure the bHaptics Player application is running on your computer.

Further Reading

You're now ready to use the bHaptics haptic feature! Visit our JavaScript Reference to play haptics in your project, or refer the complete example code below.

If you have troubles for using this library, check the Troubleshooting.