@nexussdk/sdk
v0.0.4
Published
Unified umbrella SDK for Nexus Platform — feature flags + error tracking + React hooks
Maintainers
Readme
@nexussdk/sdk
The official umbrella client SDK for the Nexus Platform — high-performance feature flags, error telemetry, and React hooks with zero runtime bloat (<8KB gzipped).
Features
- 🚩 Feature Flags & Remote Config: Deterministic Murmur3 hashing, ABAC evaluation rules, and real-time SSE streaming updates.
- ⚡ Error Telemetry & Monitoring: Automatic uncaught exception catching, unhandled promise rejection tracking, and regex-based PII scrubbing.
- ⚛️ First-Class React 19 Support: Idiomatic hooks (
useFlag,useNexus) andNexusProvidercontext wrapper. - 🪶 Ultra Lightweight: Zero heavy dependencies, tree-shakeable, and sub-8KB gzipped footprint.
- 🔒 Type Safe: Strict TypeScript contracts and autocomplete out of the box.
Installation
# npm
npm install @nexussdk/sdk
# pnpm
pnpm add @nexussdk/sdk
# yarn
yarn add @nexussdk/sdkQuick Start (Vanilla / Node / Browser)
import { createNexus } from '@nexussdk/sdk';
const nexus = createNexus({
clientKey: 'pk_live_your_client_key',
baseUrl: 'https://api.nexusplatform.io',
environment: 'production',
user: {
id: 'usr_123',
email: '[email protected]',
role: 'premium',
},
});
// 1. Evaluate feature flag
const isNewCheckout = await nexus.flags.isEnabled('new-checkout-flow', false);
if (isNewCheckout) {
// Render new checkout
}
// 2. Capture error with breadcrumbs
try {
// your app logic
} catch (error) {
nexus.tracker.captureException(error, {
tags: { module: 'checkout' },
});
}React Integration
Wrap your application in NexusProvider:
import React from 'react';
import { NexusProvider, useFlag, useNexus } from '@nexussdk/sdk/react';
function App() {
return (
<NexusProvider
config={{
clientKey: 'pk_live_your_client_key',
baseUrl: 'https://api.nexusplatform.io',
}}
>
<CheckoutPage />
</NexusProvider>
);
}
function CheckoutPage() {
const isV2Enabled = useFlag('v2-checkout-button', false);
const nexus = useNexus();
const handleCheckout = () => {
nexus.tracker.addBreadcrumb('Clicked checkout', 'ui');
// Proceed to checkout
};
return (
<button onClick={handleCheckout}>
{isV2Enabled ? 'Express Checkout' : 'Standard Checkout'}
</button>
);
}Vue 3 & Nuxt 4 Integration
Install NexusPlugin and use the <NexusGuard> error boundary component:
// main.ts
import { createApp } from 'vue';
import { NexusPlugin } from '@nexussdk/sdk/vue';
import App from './App.vue';
const app = createApp(App);
app.use(NexusPlugin, {
apiKey: 'pk_live_your_client_key',
environment: 'production',
autoCapture: true,
realtime: true,
});
app.mount('#app');<!-- App.vue -->
<script setup lang="ts">
import { useFeatureFlag, NexusGuard } from '@nexussdk/sdk/vue';
const { isEnabled } = useFeatureFlag('new-checkout-flow', false);
</script>
<template>
<NexusGuard>
<button v-if="isEnabled">1-Click Express Checkout</button>
<button v-else>Standard Checkout</button>
</NexusGuard>
</template>Architecture & Subpackages
@nexussdk/sdk bundles the following specialized modules for maximum modularity:
| Package | Role |
|---|---|
| @nexussdk/contracts | SSOT TypeScript types and RFC 7807 error models |
| @nexussdk/core | Ring buffer transport kernel and environment resolvers |
| @nexussdk/flags | Standalone feature flag evaluator, local dev server (nexus-flags-dev) & SSE manager |
| @nexussdk/tracker | Standalone error tracker, local dev server (nexus-dev) & PII sanitizer |
License
MIT © Nexus Platform
