Full-stack framework — islands-first HTML, Svelte 5 runes, server actions, file-based routes, streaming SSR, and production-ready deployment.
Website — nexusjs.dev · Documentation · Examples · Changelog
Nexus is a security-first, production-ready web framework that combines:
$state, $derived, $effect for reactive UI+page.nx, +layout.nx, [params]Most frameworks force you to choose between simplicity and production-readiness. Nexus gives you both:
npm create @nexus_js/nexus my-app
cd my-app
npm install
npm run dev
Visit http://localhost:3000 and start building!
Create src/routes/+page.nx:
---
// Server-only code (runs once per request)
const greeting = "Hello, Nexus!";
export async function load(ctx) {
return { user: { name: "Developer" } };
}
---
<h1>{greeting}</h1>
<p>Welcome, {pretext.user.name}</p>
<!-- Interactive island -->
<div client:load>
<script>
let count = $state(0);
</script>
<button onclick={() => count++}>
Clicked {count} times
</button>
</div>
<style>
h1 { color: #5b21b6; }
button {
padding: 0.5rem 1rem;
background: #5b21b6;
color: white;
border: none;
border-radius: 0.375rem;
cursor: pointer;
}
</style>
Ship only the JavaScript you need. Static HTML by default, JavaScript where needed:
<!-- Static -->
<h1>Fast, SEO-friendly content</h1>
<!-- Interactive island (hydrates in browser) -->
<div client:load>
<script>
let open = $state(false);
</script>
<button onclick={() => open = !open}>Toggle</button>
{#if open}<p>Dynamic content</p>{/if}
</div>
Hydration strategies: client:load, client:idle, client:visible, client:media="(min-width: 768px)"
No configuration needed — security is built-in:
Type-safe backend calls without writing API routes:
---
import { z } from 'zod';
export async function createPost(formData, ctx) {
// Rate limiting built-in
if (!ctx.rateLimit('createPost', { max: 10, window: 60_000 })) {
return { error: 'Too many requests', status: 429 };
}
// Validation with Zod
const result = z.object({
title: z.string().min(3),
content: z.string().min(10),
}).safeParse({
title: formData.get('title'),
content: formData.get('content'),
});
if (!result.success) return { error: 'Invalid input' };
await db.posts.create(result.data);
return { redirect: '/posts' };
}
---
<form method="post" action="/_nexus/action/createPost">
<input name="title" required />
<textarea name="content" required></textarea>
<button type="submit">Create Post</button>
</form>
Production-ready GraphQL with built-in security:
import { createGraphQLHandler } from '@nexus_js/graphql';
import { nexusVault } from '@nexus_js/security';
const handler = createGraphQLHandler({
schema,
shield: {
maxCost: 500, // Prevent expensive queries
maxDepth: 8, // Limit nesting
allowIntrospection: false,
},
mask: {
'User.passwordHash': null, // Redact sensitive fields
'User.apiKey': (val, ctx) =>
ctx.user?.role === 'admin' ? val : null,
},
rateLimit: { max: 60, windowMs: 60_000 },
});
// Mount at /graphql
export default {
server: {
mounts: [{ path: '/graphql', handler }],
},
};
Migrate existing backends without downtime:
import { createRemoteExecutor, wrapExpressMiddleware } from '@nexus_js/graphql';
// Proxy to old GraphQL API
const legacyApi = createRemoteExecutor({
url: 'https://old-api.company.com/graphql',
headers: { 'x-api-key': vault.get('LEGACY_KEY') },
});
// Wrap Express middleware as Nexus action
export const legacyPayment = wrapExpressMiddleware(oldExpressHandler);
// HTTP fallback proxy
export default {
server: {
fallbackProxy: 'http://localhost:8080', // Old backend
},
};
This repository includes production-ready examples:
Run any example:
cd examples/paylinks-saas
pnpm install
pnpm dev
# Build image
docker build -t my-nexus-app .
# Run with docker-compose
docker-compose up -d
# Build for production
npm run build
# Start server
NODE_ENV=production npm start
# Required
NEXUS_SECRET="your-32-character-secret"
DATABASE_URL="postgresql://..."
# Optional
NEXUS_PORT=3000
STRIPE_SECRET_KEY="sk_live_..."
See Deployment Guide for VPS, Docker, and CI/CD setup.
nexus/
├── packages/
│ ├── cli/ # nexus dev, build, studio
│ ├── server/ # HTTP server, SSR, actions
│ ├── compiler/ # .nx parser & codegen
│ ├── runtime/ # Client-side (islands, navigation)
│ ├── graphql/ # GraphQL integration (NEW in 0.9.3)
│ ├── security/ # Vault, Shield, CSRF
│ ├── router/ # File-based routing
│ └── ... # 20+ packages total
├── examples/
│ ├── paylinks-saas/ # Full SaaS example
│ ├── basic/
│ └── pokedex/
└── docs/ # Contributor guides
Requirements: Node.js ≥22, pnpm ≥9
# Clone repo
git clone https://github.com/bierfor/nexus.git
cd nexus
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Start example
pnpm example
See CONTRIBUTING.md for detailed development guide.
MIT © 2024-2026 Nexus.js Contributors
See LICENSE for details.
Built with ❤️ by bierfor
| Area | Highlights |
|---|---|
| Rendering | Islands, streaming SSR, automatic cache-related Cache-Control hints |
| Data | Pretext merged into $pretext(), cache() with tags/TTL |
| Client | Global store, optimistic updates, SPA-style navigation where enabled |
| Tooling | `nexus dev |
Issues and pull requests are welcome. See CONTRIBUTING.md (setup, structure, commits, tests). To replace or recreate the GitHub remote with a clean tree only, follow docs/REPOSITORY.md.
MIT — see LICENSE.