Registry / database / hocuspocus-extension-postgres

hocuspocus-extension-postgres

JSON →
library0.1.1jsnpmunverified

A generic persistence driver for Hocuspocus that stores Y.js document updates in PostgreSQL. This is a community extension (v0.1.1) with no active release schedule. It integrates with the Hocuspocus server ecosystem, allowing collaborative editing data to be persisted in Postgres. It is an alternative to SQLite or other backends, providing SQL-based storage for Hocuspocus-based applications. The package ships TypeScript types. Note: v0.1.1 is early-stage; expect breaking changes.

npm install hocuspocus-extension-postgres
INSTALL
IMPORT
SIG · HOCUSPOCUS-EXTENSI
H
hocuspocus-extension-postgres
databasejavascriptv0.1.1
harness data pending
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.

Postgres
import { Postgres } from 'hocuspocus-extension-postgres'
import Postgres from 'hocuspocus-extension-postgres'
Named export only; default import will fail.
Postgres
import { Postgres } from 'hocuspocus-extension-postgres'
const { Postgres } = require('hocuspocus-extension-postgres')
ESM-only package; CommonJS require() will error.
PostgresOptions
import type { PostgresOptions } from 'hocuspocus-extension-postgres'
TypeScript users can import the options type for configuration objects.

Sets up a Hocuspocus server with PostgreSQL persistence extension using environment variable for connection.

import { Logger } from '@hocuspocus/extension-logger' import { Server } from '@hocuspocus/server' import { Postgres } from 'hocuspocus-extension-postgres' const port = process.env.PORT ?? 1234 const server = Server.configure({ port, extensions: [ new Logger(), new Postgres({ connectionString: process.env.DATABASE_URL ?? 'postgres://postgres@localhost:5432/postgres', }), ], }) server.listen() console.log(`Server running on port ${port}`)
Debug
Known issues
breakingPackage version 0.x indicates API instability; breaking changes between minor versions.
fix
Pin to specific version and test upgrades; consider using a stable Hocuspocus extension like @hocuspocus/extension-sqlite for production.
affects: <1.0.0
gotchaRequires Postgres connection string; missing or invalid string causes server startup failure.
fix
Ensure DATABASE_URL environment variable is set or pass a valid connectionString option.
affects: *
gotchaESM-only package; importing via require() will throw error.
fix
Use import syntax or configure your project to support ESM (e.g., type: 'module' in package.json).
affects: *
deprecatedNo active maintenance as of 2023; consider using official persistence extensions.
fix
Evaluate @hocuspocus/extension-sqlite or build custom driver with @hocuspocus/extension-database interface.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using require() on an ESM-only package.
fix
Switch to import syntax or set type: 'module' in package.json.
TypeError: (0 , _hocuspocusExtensionPostgres.Postgres) is not a constructor
Default import used instead of named import.
fix
Use import { Postgres } from 'hocuspocus-extension-postgres'
Error: connect ECONNREFUSED ::1:5432
PostgreSQL not running or connection string is incorrect.
fix
Ensure PostgreSQL is running and connection string is correct; set DATABASE_URL environment variable.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
@hocuspocus/serverrequiredRequired to configure the Hocuspocus server and use the extension.
pgrequiredPostgreSQL client library used internally for database connections.
Agent activity
7 hits · last 30 days
node
6
Resources
hocuspocus-extension-postgres — npm install hocuspocus-extension-postgres · libregistry