🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@domstack/sync

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domstack/sync

A modern, minimal live-reload dev server

Source
npmnpm
Version
0.0.3
Version published
Weekly downloads
113
-41.75%
Maintainers
1
Weekly downloads
 
Created
Source

@domstack/sync

latest version Actions Status downloads neostandard javascript style Socket Badge

A modern, dependency-minimized live-reload dev server. A love letter to browser-sync: ESM-only, Fastify, native WebSocket, and a server-rendered HTMX UI panel.

Install

npm install @domstack/sync

CLI

# Serve current directory, watch CSS and HTML
domstack-sync --server . --files '**/*.css' '**/*.html'

# Watch files without serving (snippet-injection mode)
domstack-sync --files '**/*.css'

# Short alias
dss --server . --files '**/*'

# Disable the UI panel
domstack-sync --server . --no-ui

# Write a starter config file
domstack-sync init

# Trigger a reload from another terminal
domstack-sync reload --port 3000

CLI flags

FlagDefaultDescription
--server, -sDirectory to serve
--files, -fGlob patterns to watch (repeatable)
--port3000Port to listen on
--no-uiDisable the UI panel
--no-notifyDisable the notification overlay
--no-ghost-modeDisable scroll/click/form sync
--corsEnable CORS headers
--log-levelinfosilent | debug | info | warn | error
--log-connectionsLog browser connection events at info level
--help, -hShow help text
--version, -vShow version

API

import { createServer, parseOptions } from '@domstack/sync'

const sync = await createServer({
  server: './public',
  files: ['public/**/*.css', 'public/**/*.html'],
  port: 3000,
})

console.log(sync.url)    // http://localhost:3000
console.log(sync.uiUrl)  // http://localhost:3001

// Trigger a full reload
sync.reload()

// CSS-inject a specific file (falls back to full reload if not matched)
sync.reload(['styles/main.css'])

// Show a notification overlay in connected browsers
sync.notify('Build complete')

// Stream integration — pipe any { path } objects through to trigger reloads
someReadableStream.pipe(sync.stream())

// Listen for server-side events
sync.events.on('client:connect', (info) => console.log('connected', info.ua))
sync.events.on('client:disconnect', (id) => console.log('disconnected', id))
sync.events.on('file:change', (evt) => console.log('changed', evt.path))

// Pause / resume watcher-triggered reloads (e.g. during a build)
sync.pause()
sync.resume()

// Graceful shutdown
await sync.exit()

Options

OptionTypeDefaultDescription
portnumber3000Port to listen on (falls back to OS-assigned if taken)
serverstring | falsefalseDirectory to serve statically
filesstring[][]Glob patterns to watch for changes
ghostMode{ scroll, clicks, forms }all trueSync interactions across connected browsers
logLevel'silent' | 'debug' | 'info' | 'warn' | 'error''info'Log verbosity
logConnectionsbooleanfalseLog browser connection events at info level
uiboolean | { port: number }trueUI panel — false disables, { port } pins the port
notifybooleantrueShow notification overlay in connected browsers
corsbooleanfalseAdd CORS headers to all responses
injectChangesbooleantrueCSS-inject .css changes instead of full reload
reloadDebouncenumber500Milliseconds to debounce file-change reloads
reloadDelaynumber0Milliseconds to delay reload after a change
watchOptionsobject{}Options passed through to chokidar
cwdstringprocess.cwd()Working directory for resolving server and files

TypeScript

All types are exported:

import type { BsInstance, BsOptions, BsOptionsInput } from '@domstack/sync'
import type { ServerToClientMessage, ClientToServerMessage } from '@domstack/sync'

How it works

  • Script injection — an IIFE <script> tag is injected before </body> (or appended if there is no </body>) in every HTML response. The injected script connects to the WebSocket server.
  • CSS injection — when a watched .css file changes and injectChanges: true, the matching <link rel="stylesheet"> has its href cache-busted in place without a full page reload. Falls back to a full reload if no matching stylesheet is found.
  • Ghost mode — scroll position, clicks, and form input changes in one browser are relayed to all other connected browsers via the WebSocket server. Disable with ghostMode: false or --no-ghost-mode.
  • UI panel — a separate Fastify server on an auto-detected port shows connected browsers, file-change history, and server URLs. Disable with ui: false or --no-ui.
  • Port selection — the requested port is tried first. If it is already in use, the OS assigns a free ephemeral port automatically.

License

MIT

Keywords

live-reload

FAQs

Package last updated on 02 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts