Back to Getting Started

Installing the LiteSOC Node.js SDK

Learn how to install and configure the LiteSOC Node.js SDK in your application.

Last updated: 2026-03-01

Installing the LiteSOC Node.js SDK

The LiteSOC Node.js SDK provides a simple and efficient way to send security events from your Node.js applications. This guide will walk you through the installation and initial configuration.

Prerequisites

Before you begin, make sure you have:

  • Node.js 18+ installed on your machine
  • A LiteSOC account with an active API key
  • npm or yarn package manager

Step 1: Install the SDK

Install the LiteSOC SDK using your preferred package manager:

# Using npm
npm install @litesoc/node

# Using yarn
yarn add @litesoc/node

# Using pnpm
pnpm add @litesoc/node

Step 2: Get Your API Key

  1. Log in to your LiteSOC Dashboard
  2. Navigate to SettingsAPI Keys
  3. Click Create New API Key
  4. Copy the generated key (you won't be able to see it again)

⚠️ Important: Never commit your API key to version control. Use environment variables instead.

Step 3: Initialize the Client

Create a new file or add to your existing configuration:

import { LiteSOC } from '@litesoc/node';

const litesoc = new LiteSOC({
  apiKey: process.env.LITESOC_API_KEY!,
  // Optional: specify the region (default: 'us')
  region: 'us',
});

export default litesoc;

Step 4: Configure Environment Variables

Add your API key to your environment:

# .env.local
LITESOC_API_KEY=lsk_live_xxxxxxxxxxxxxxxxxxxx

Step 5: Verify the Installation

Test your setup by sending a simple event:

import litesoc from './litesoc';

async function testConnection() {
  try {
    await litesoc.track({
      event: 'auth.login.success',
      actor: {
        id: 'test-user-123',
        email: 'test@example.com',
      },
      metadata: {
        test: true,
      },
    });
    console.log('✅ LiteSOC connected successfully!');
  } catch (error) {
    console.error('❌ Connection failed:', error);
  }
}

testConnection();

TypeScript Support

The SDK is written in TypeScript and includes full type definitions. You'll get autocomplete and type checking out of the box.

import { LiteSOC, SecurityEvent } from '@litesoc/node';

const event: SecurityEvent = {
  event: 'auth.login.success',
  actor: {
    id: 'user-123',
    email: 'user@example.com',
  },
};

Next Steps

Troubleshooting

"Invalid API Key" Error

Make sure your API key:

  • Starts with lsk_live_ (production) or lsk_test_ (sandbox)
  • Has not been revoked in the dashboard
  • Is correctly set in your environment variables

"Network Error" or Timeout

Check that:

  • Your firewall allows outbound connections to api.litesoc.io
  • You have a stable internet connection
  • The LiteSOC status page shows no outages

Need help? Contact our support team or check our API documentation.

Related Articles

Was this article helpful? Need more assistance?