Skip to content

fabudde/nyxcode

Repository files navigation

🦞 NyxCode

The AI-native programming language. One .nyx file = full-stack app.

CI npm Tests License: MIT

🌐 nyxcode.io Β· 🎨 demo.nyxcode.io Β· πŸ“Š NyxStatus.com (378 lines of NyxCode)


Why NyxCode?

AI writes most code in 2026. But it still thinks in React, Vue, and raw HTML β€” languages designed for humans in the '90s. Every token costs money, time, and context window.

NyxCode: 3.5x fewer tokens than Next.js. 71% cheaper AI generation.

NyxCode Next.js Savings
Lines 378 1,069 65% fewer
Files 1 27 27x fewer
Tokens ~2,733 ~9,476 3.5x fewer
AI cost ~$0.20 ~$0.71 71% cheaper

Real benchmark: NyxStatus.com β€” identical full-stack SaaS, measured with cl100k_base.

Quick Start

npm i -g @fabudde/nyxcode
nyx build app.nyx -o dist/        # Static site
nyx build app.nyx                 # Full-stack (auto-detects tables/api)
nyx check app.nyx                 # Validate only, no output (great for CI / AI loops)
nyx dev app.nyx                   # Dev server + hot reload
nyx add stripe                    # Add package + npm install

Full-Stack in 16 Lines

table posts { title text required, body text, created auto }
security { table users, login email password, token jwt, protect /api/posts write }
theme { colors { primary #667eea, bg #0a0a12 } }
preset card { bg card, r 12px, p 2rem }

page / {
  section style={ mw 800px, mx auto, p 2rem } {
    h1 "My Blog"
    form /api/posts auth { input title, submit "Post", success -> reload }
    data posts = get /api/posts auth
    each posts -> div preset=card { h3 .title, p .body }
  }
}
page /register {
  form /api/auth/register { input email, input password, submit "Register", success -> redirect / }
}

Generates: index.html, register/index.html, AND server.js with 10 CRUD endpoints, JWT auth, and SQLite. Zero config.

React vs NyxCode

React β€” 20+ lines, 80+ tokens:

import React, { useState, useEffect } from 'react';
export default function UserList() {
  const [users, setUsers] = useState([]);
  useEffect(() => {
    fetch('/api/users').then(r => r.json()).then(setUsers);
  }, []);
  return (
    <div className="container">
      {users.map(u => (
        <div key={u.id} className="card">
          <h3>{u.name}</h3><p>{u.email}</p>
        </div>
      ))}
    </div>
  );
}

NyxCode β€” 4 lines, 26 tokens:

page /users {
  data users = get /api/users
  each users -> card { h3 .name, p .email }
}

Same result. 76% fewer lines. 68% fewer tokens.


v0.51 β€” Beautiful Defaults ✨

Every NyxCode page now ships with professional defaults β€” zero CSS required.

🎨 See it live β†’ demo.nyxcode.io

What you get for free:

  • Typography β€” clamp() fluid sizing, -0.025em letter-spacing on headings, 1.7 line-height on body text
  • Buttons β€” Rounded, hover states, active scale, disabled opacity
  • Inputs/Select/Textarea β€” Focus glow, placeholder styling, border transitions
  • Select dropdowns β€” Readable options on any background (light or dark)
  • Links β€” Smooth color transitions, underline-offset on hover
  • Tables β€” Collapsed borders, uppercase headers, consistent padding
  • Code β€” Monospace font stack, subtle background, padded pre blocks
  • Details/Summary β€” Styled accordion with border and open-state separator
  • Lists β€” Proper padding, disc/decimal markers
  • Scroll β€” Smooth scrolling
  • Focus β€” :focus-visible only (no ugly outlines on click)
  • Selection β€” Themed purple highlight
  • Disabled β€” 50% opacity + pointer-events: none

All defaults use :where() β€” zero specificity. Your styles always win.


Features at a Glance

🎨 Themes & Design Tokens

theme {
  colors { primary #667eea, bg #0a0a12, surface #1a1a2e }
  fonts { body Inter, source: google }
  body { bg #0a0a12, c #f0eaff }
  selection { bg rgba(155,142,196,0.3) }
  defaults { a { c primary, td none } }
}
preset card { bg surface; r 12px; p 2rem }

πŸ“± Responsive

div grid=3@1 gap=2rem { ... }       # 3 cols β†’ 1 col on mobile
nav burger brand="MySite" { ... }    # Accessible hamburger menu, zero JS
style { @mobile { fs 0.9rem } }      # Built-in breakpoints

🧩 Components

component Card(title, desc, status="Active") {
  div preset=card {
    h3 "${title}"
    p "${desc}"
    span "${status}"
  }
}
page / { use Card("Hello", "World") }

⚑ Client-Side Reactivity

page / {
  let count = 0
  h1 "Count: ${count}"
  button "+" @click { count += 1 }
}

πŸ” Auth & Security

security { table users, login email password, token jwt, protect /api/posts write }
page /dashboard auth { ... }
a "Login" visible=guest
a "Dashboard" visible=auth

πŸ“Š Data Binding

data posts = get /api/posts auth {
  loading -> p "Loading..."
  empty -> p "No posts yet"
  error -> p "Something went wrong"
}
each posts -> div { h3 .title, p .body }

πŸ—ƒοΈ Database + Auto-Migrations

table posts {
  title text required
  body text
  author [users]              # Foreign key β†’ auto JOIN
  created auto
  category text default="general"   # Add columns β†’ auto-migrated
}

πŸ”— Pipe β€” Declarative Logic Chains

pipe 'new-order' {
  on api POST /api/orders auth
  validate $body.email is email
  query "INSERT INTO orders (email, total) VALUES ($body.email, $body.total)" as result
  notify email to=$body.email subject="Order #${result.id}"
  respond 201 { id: $result.id, status: created }
}

🎯 Native Icons

theme { icons: lucide }
icon "heart" size=24
h1 "icon:map-pin Our Location"

🎬 Animations

keyframes fadeIn {
  from { op 0 }
  to { op 1 }
}

CSS Shorthands

100+ shorthands β€” write less, ship faster:

Short CSS Short CSS
bg background c color
m / p margin / padding mx / px margin-inline / padding-inline
w / h width / height mw / mh max-width / max-height
fs font-size fw font-weight
r border-radius shadow box-shadow
d display pos position
op opacity tr transition
tf transform ai align-items

Full list β†’

Tailwind Compatibility

Already know Tailwind? Use those classes in NyxCode β€” compiled to native CSS at build time, zero runtime:

div class="flex items-center gap-4 p-6 rounded-xl bg-white shadow-lg" {
  h2 class="text-2xl font-bold text-gray-900" "Hello"
}

Architecture

.nyx β†’ Lexer β†’ Parser β†’ AST β†’ Compiler β†’ HTML + CSS + JS
                                        β†’ Express + SQLite (if backend detected)

Single pipeline. No webpack. No bundler config. No node_modules for frontend.

A full-stack build emits a runnable backend: server.js plus a package.json (pinned deps + npm start) and a README β€” so npm install && npm start just works.

Editor Support

Syntax highlighting and editor config for VS Code live in editors/vscode.

cp -r editors/vscode ~/.vscode/extensions/nyxcode-0.53.0   # then reload VS Code

Development & Testing

npm install        # install toolchain + backend deps (for e2e)
npm run build      # tsc -> dist/
npm run typecheck  # strict type-check, no emit
npm test           # 717 unit tests (lexer/parser/compiler/security/...)
npm run test:e2e   # 9 end-to-end tests: boot the generated server, hit it over HTTP
npm run test:all   # build + unit + e2e

Unit tests assert on generated output; the end-to-end suite compiles real apps with the CLI, starts the generated Express + SQLite server, and exercises live HTTP (CRUD persistence, validation, static frontend, auth register/login/JWT). CI runs the whole thing on Node 20/22/24.

NyxStatus β€” The Proof

378 lines. One file. Full SaaS.

nyxstatus.com β€” Uptime monitoring with JWT auth, SQLite DB, CRUD API, background health checks, email alerts, cascade deletes, responsive dark theme. 100% NyxCode.

Versions

Version Highlights
v0.53.0 Runnable & Reliable β€” Generated backends ship a package.json (npm start works), ?? / ?. operators, CI, end-to-end runtime tests, VS Code highlighting
v0.52.0 Store System v2 β€” Persistent stores, $reset(), $patch(), methods
v0.51.0 Beautiful Defaults β€” Professional typography, interactive elements, focus management, select fix, all zero-config
v0.50.0 Zero Patches β€” SolidJS reactivity, custom API routes, query aliases, when-inside-each, stdlib
v0.39.0 The Language Release II β€” Arrays, objects, loops, mutable vars, reactivity
v0.32.0 pipe β€” Declarative logic chains, 16 step types
v0.30.0 The Language Release β€” let, action, on, env, email, use
v0.25.x Body styles, keyframes, selection, element defaults
v0.24.x Burger nav, multi-file imports, Figma import

Created By

Fabian Budde 🐻 β€” Creator & Language Design Nyx 🦞 β€” Lead Developer & Compiler Engineering β€” @NyxTheLobster Tyto πŸ¦‰ β€” Architecture & Security Review β€” @heyTyto Kiro 🐺 β€” QA & Technical Documentation

A human and three AIs building the language that bridges both worlds.

License

MIT


NyxCode v0.53.0 β€” 717 unit + 9 e2e tests β€” npm β€” NYXCODE.md (full AI context) β€” demo.nyxcode.io

🦞