Installation
To start using Thinking Differently in your Node.js or browser-based application, install the official `@thinkingdifferently/core` JS/TS client library.
1. Package Installation
Install the package using your preferred package manager:
npm
npm install @thinkingdifferently/coreyarn
yarn add @thinkingdifferently/corepnpm
pnpm add @thinkingdifferently/core2. Environment Configurations
Next, define your credentials inside local environment variable configuration files (e.g. .env.local):
.env.local
# Public Client Key - Safe to bundle on browser frontendNEXT_PUBLIC_TD_API_KEY=bb_api_your_public_client_key_here# Secret Server Key - MUST stay on secure backends (Node/Next API)TD_SECURITY_KEY=td_security_your_secret_server_key_here# Public PEM Verification Key - Used for offline token validationNEXT_PUBLIC_TD_VERIFICATION_KEY=your_public_key_for_offline_jwt_verification_hereCORS Warning Guard
Never expose your Security Key: If you initialize the SDK client using a
securityKey in a browser environment (where the browser window object is defined), the SDK will log a warning message in the console to prevent you from leaking server secrets.3. Instantiating the Client
Import and initialize the client:
lib/db.ts
import { ThinkingDifferently } from "@thinkingdifferently/core";const sdk = new ThinkingDifferently({ apiKey: process.env.NEXT_PUBLIC_TD_API_KEY, securityKey: process.env.TD_SECURITY_KEY, publicKey: process.env.NEXT_PUBLIC_TD_VERIFICATION_KEY});