In this guide, we will create the Logux server for the simplest case:

If you want to use another language for the server read Logux Proxy page.

Creating the Project

Install Node.js (version 12.0 or later).

Create a directory for a project. We will use server-logux name.

mkdir server-logux
cd server-logux

Create package.json with:

  "name": "server-logux",
  "private": true,
  "type": "module",
  "scripts": {
    "start": "node index.js"

Install Logux Server:

  • npm i @logux/server

    Create index.js with:

    import { Server } from '@logux/server'
    const server = new Server(
      Server.loadOptions(process, {
        subprotocol: '1.0.0',
        supports: '1.x',
        fileUrl: import.meta.url
    server.auth(({ userId, token }) => {
      // Allow only local users until we will have a proper authentication
      return process.env.NODE_ENV === 'development'

    The simple Logux server is ready. You can start it with:

  • npm start

    To stop the server press Command+. on Mac OS X and Ctrl+C on Linux and Windows.


    Logux Server supports any database. We will use PostgreSQL only as an example.

    Install PostgreSQL.

    Install PostgreSQL tools for Node.js:

  • npm i dotenv pg-promise node-pg-migrate pg

    Start database depends on your environment.

    Create database. Use this advice if you will have role does not exist error.

    createdb server-logux

    Create .env file with URL to your database. Put this file to .gitignore.


    Create new migration for database schema:

    npx node-pg-migrate create create_users

    Open generated file from migrations/ and create users table:

    exports.up = pgm => {
      pgm.createTable('users', {
        id: 'id',
        email: { type: 'varchar', notNull: true, unique: true },
        password: { type: 'varchar', notNull: true }
    exports.down = pgm => {

    Run migration:

    npx node-pg-migrate up

    Connect to the database in index.js:

    const { Server } = require('@logux/server')
    const pg = require('pg-promise')
    const server = new Server(
      Server.loadOptions(process, {
        subprotocol: '1.0.0',
        supports: '1.x',
        root: __dirname
    let db = pg()(process.env.DATABASE_URL)

    Look at Node.js API to see what you can do next.