Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
StelarServer
✓ import { StelarServer } from 'stelar-time-real';
✗ import StelarServer from 'stelar-time-real';
Named export, not default. TypeScript types included.
StelarClient
✓ import { StelarClient } from 'stelar-time-real';
✗ const { StelarClient } = require('stelar-time-real');
ESM-only. CommonJS require will work but may cause issues with named exports.
default import
✓ import { StelarServer, StelarClient } from 'stelar-time-real';
✗ import Stelar from 'stelar-time-real';
No default export; all symbols named.
Shows basic server setup with Express and client connection. Express is optional; StelarServer works with any HTTP server or standalone.
import express from 'express';
import { StelarServer, StelarClient } from 'stelar-time-real';
const app = express();
const server = app.listen(3000);
const stelar = new StelarServer({ server });
stelar.onConnection((client) => {
console.log('New client:', client.id);
client.emit('welcome', 'Hello! Welcome to stelar-time-real');
});
stelar.on('message', (ctx) => {
ctx.broadcast('message', ctx.data);
});
stelar.start();
// Client side
const client = new StelarClient('localhost:3000');
client.connect();
client.on('welcome', (msg) => console.log(msg));
Errors
Common errors & fixes
StelarServer is not a constructor
Importing default export instead of named export.
fixUse '{ StelarServer }' in import statement. Cannot find module 'stelar-time-real'
Package not installed or incorrect path.
fixRun 'npm install stelar-time-real'
TypeError: Cannot read properties of undefined (reading 'emit')
Client not connected yet when calling emit.
fixEnsure emit occurs after 'connect' event.
Audit
Dependencies
wsoptionalNative WebSocket implementation used by both server and client (Web API in browsers, ws in Node.js)