npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nexabase-console

v1.0.4

Published

SDK Client resmi untuk NexaBase: Platform Sinkronisasi NoSQL, Realtime, File Storage, & Autentikasi Offline-First.

Readme

NexaBase JavaScript SDK (nexabase-console)

SDK Client Resmi untuk NexaBase: Platform sinkronisasi database modern yang menyatukan fungsionalitas Firestore NoSQL, Real-Time Database, File Storage, dan Edge Authentication dengan dukungan Offline-First (IndexedDB) serta Passwordless OTP.


🚀 Fitur Utama

  • ⚡ Real-Time Synchronization: Sinkronisasi data real-time dengan latency rendah menggunakan Server-Sent Events (SSE).
  • 📦 Offline-First & Auto-Sync: Sinkronisasi state lokal secara otomatis menggunakan IndexedDB. Data tetap tersimpan di browser jika koneksi terputus dan akan disinkronkan ke server secara otomatis saat kembali online.
  • 🔥 Modular Firestore API: Desain API modular modern mirip Firebase SDK (v9+) sehingga sangat mudah dipelajari.
  • 🔑 Secure Auth & Passwordless OTP: Dukungan penuh registrasi, login email/sandi, serta OTP instan via SMTP yang aman.
  • 📂 File Storage Integration: Unggah aset media dan file blob ke cloud storage dengan satu perintah.

📦 Instalasi

Instal package melalui npm atau yarn:

npm install nexabase-console
# atau
yarn add nexabase-console

🛠️ Cara Penggunaan & Contoh Kode

1. Inisialisasi Aplikasi

import { initializeApp, getFirestore } from 'nexabase-console';

const app = initializeApp({
  projectId: 'PROYEK_NEXABASE_ID_ANDA',
  apiKey: 'NEXABASE_API_KEY_ANDA' // Opsional, default endpoint mengarah ke https://db.nexabase.id
});

const db = getFirestore(app);

2. Firestore-like Modular API (NoSQL)

Menulis Data Baru (Set Doc)

import { doc, setDoc } from 'nexabase-console';

const main = async () => {
  const profileRef = doc(db, 'users', 'budi_santoso');
  const res = await setDoc(profileRef, {
    name: 'Budi Santoso',
    email: '[email protected]',
    age: 28,
    hobbies: ['Coding', 'Cycling']
  });
  
  console.log("Data berhasil disimpan:", res);
};

main();

Memperbarui Sebagian Data (Update Doc)

import { doc, updateDoc } from 'nexabase-console';

const editData = async () => {
  const profileRef = doc(db, 'users', 'budi_santoso');
  await updateDoc(profileRef, {
    age: 29 // Hanya memperbarui field age
  });
};

Membaca Satu Dokumen (Get Doc)

import { doc, getDoc } from 'nexabase-console';

const readData = async () => {
  const profileRef = doc(db, 'users', 'budi_santoso');
  const snapshot = await getDoc(profileRef);
  
  if (snapshot.exists()) {
    console.log("Isi data:", snapshot.data());
  } else {
    console.log("Dokumen tidak ditemukan.");
  }
};

Mendengarkan Perubahan Data secara Real-Time (onSnapshot)

import { doc, onSnapshot } from 'nexabase-console';

const listenLive = () => {
  const docRef = doc(db, 'chats', 'global_room');
  
  // onSnapshot akan terpanggil seketika jika ada perubahan data baik di lokal maupun di server
  const unsubscribe = onSnapshot(docRef, (snapshot) => {
    console.log("⚡ Perubahan Terdeteksi! Data Terbaru:", snapshot.data());
  });
  
  // Panggil unsubscribe() untuk menghentikan pemantauan realtime
  // unsubscribe();
};

Menggunakan Atomic Write Batch

import { doc, writeBatch } from 'nexabase-console';

const executeBatch = async () => {
  const batch = writeBatch(db);
  
  const ref1 = doc(db, 'products', 'prod_a');
  const ref2 = doc(db, 'products', 'prod_b');
  
  batch.set(ref1, { name: 'Sandal Kulit', price: 75000 });
  batch.set(ref2, { name: 'Sepatu Kulit', price: 250000 });
  
  const result = await batch.commit();
  console.log("Semua operasi batch berhasil di-commit secara atomik.");
};

3. Autentikasi Pengguna & OTP Tanpa Sandi

Pendaftaran & Login Tradisional

// Registrasi User Baru
const register = async () => {
  const user = await app.auth().createUserWithEmailAndPassword(
    '[email protected]', 
    'password123', 
    'Andi Wijaya'
  );
  console.log("Registrasi Berhasil:", user);
};

// Login User
const login = async () => {
  const authSession = await app.auth().signInWithEmailAndPassword(
    '[email protected]', 
    'password123'
  );
  console.log("Token Sesi JWT:", authSession.token);
  console.log("Data Akun Pengguna:", authSession.user);
};

Login Passwordless dengan OTP (Email)

// 1. Kirim OTP Ke Email Pengguna
const sendMyOtp = async () => {
  const res = await app.auth().sendOtp('[email protected]');
  console.log("Kode OTP berhasil terkirim ke email Anda.");
};

// 2. Verifikasi OTP dari Input Pengguna
const verifyMyOtp = async () => {
  const otpCode = '123456'; // Kode 6 digit yang dikirim ke email
  const authSession = await app.auth().signInWithOtp('[email protected]', otpCode, 'Andi Wijaya');
  console.log("Login OTP Berhasil! Sesi JWT Aktif:", authSession.token);
};

4. File Storage API

const uploadImage = async (fileBlob) => {
  const storageRef = app.storage().ref('avatars/andi.jpg');
  const result = await storageRef.put(fileBlob);
  
  console.log("Akses File URL Publik Anda:", result.url);
};

🗄️ Dukungan Sinkronisasi Offline (IndexedDB)

NexaBase JS SDK dikembangkan dengan arsitektur Offline-First.

  1. Optimistic Rendering: Jika perangkat offline, SDK akan langsung mengupdate cache IndexedDB lokal dan men-trigger callback subscriber onSnapshot agar UI pengguna langsung merespons secara instan.
  2. Background Queue: Setiap perubahan mutasi (setDoc, updateDoc, deleteDoc, writeBatch) saat offline disimpan secara aman di IndexedDB.
  3. Automatic Resync: Saat koneksi internet mendeteksi status online, antrean modifikasi akan dikirimkan kembali secara beruntun ke Server cloud NexaBase secara otomatis tanpa intervensi pengguna.

📄 Lisensi

Proyek ini dilisensikan di bawah Lisensi MIT. Bebas digunakan untuk keperluan pribadi, komersial, maupun edukasi.