# Quick Start

# Setup Server

Create new project:

Create index.js file with:

import { SocketDBServer } from 'socketdb';

SocketDBServer({ port: 8080 });

Run it with node index.js.

# Setup Client

There are two ways you can use SocketDB.

# Using script tag

Download SocketDBClient minified UMD from latest release (opens new window).

Link it in your html head:

<script src="SocketDBClient-VERSION_NUMBER.min.js"></script>

This will expose the SocketDBClient globally.

To use SocketDB as a module, you need to setup your frontend with a bundler (like rollup (opens new window)) that bundles your node_modules.

Then you can just import the browser version:

import { SocketDBClient } from 'socketdb/browser';

# Start client

Then, in your frontend javascript, you can connect to the server like this:

const db = SocketDBClient({ url: 'ws://localhost:8080' });

db.get('some').get('path').on(console.log);
db.get('some').set({ path: 'Hello World' });

Typescript

SocketDB has full typescript support. I recommend using typescript with SocketDB to get the benefits of code completion and type checking.