Files
WRNexusJSDoc/app/pages/getting-started.wrn
T

46 lines
4.5 KiB
Plaintext

page Gettingstarted {
seo {
title = "Getting started"
description = "Build and run a first WRNexusJS application after receiving private preview access."
canonical = "https://wrnexusjs.dev/getting-started"
}
view {
<SkipLink label="Skip to content" href="#main" class="docs-skip-link" />
<div class="docs-shell">
<header class="topbar"><a class="brand" href="/"><span>W</span> WRNexusJS</a><nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav><div class="topbar-actions"><a class="preview-pill" href="/access">Preview · v0.3.6</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div></header>
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
<main id="main" class="portal-main"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span aria-hidden="true">/</span><span>Documentation</span><span aria-hidden="true">/</span><span aria-current="page">Getting started</span></nav><article class="documentation prose standalone"><span class="status status-beta">Preview guide · v0.3.6</span><h1>Build a contact inbox</h1><p>This path creates a server-rendered page, validated API route, middleware, and realtime next step. It requires approved registry access and Bun 1.3.x; this site was verified with Bun 1.3.14.</p><h2 id="create">1. Create the project</h2><pre><code>bunx @wrnexus/cli@0.3.6 create my-app
cd my-app
bun install
bun run dev</code></pre><h2 id="structure">2. Know the structure</h2><pre><code>app/pages/ # file-based .wrn routes
app/components/ # reusable .wrn components
app/api/ # TypeScript request handlers
app/middleware/ # ordered request middleware
app/schemas/ # shared validation
app/realtime/ # realtime rooms
wrnexus.config.ts</code></pre><h2 id="page">3. Add a page</h2><pre><code>page Contacts &#123;
view &#123;
&lt;main&gt;&lt;h1&gt;Contact inbox&lt;/h1&gt;
&lt;form data-schema="contact" action="/api/contacts" method="post"&gt;
&lt;input name="email" type="email" /&gt;&lt;span data-error="email"&gt;&lt;/span&gt;
&lt;textarea name="message"&gt;&lt;/textarea&gt;&lt;span data-error="message"&gt;&lt;/span&gt;
&lt;button type="submit"&gt;Send&lt;/button&gt;
&lt;/form&gt;
&lt;/main&gt;
&#125;
&#125;</code></pre><h2 id="api">4. Validate an API route</h2><pre><code>import schema from "../schemas/contact";
import &#123; parseBody &#125; from "@wrnexus/validation";
export const POST = async (ctx) =&gt; &#123;
const result = await parseBody(schema, ctx.req);
return result.ok ? Response.json(&#123; ok: true &#125;, &#123; status: 201 &#125;) : result.response;
&#125;;</code></pre><h2 id="server-data">5. Load server data</h2><p>Use an <code>ssr</code> API binding and a server <code>&#123;#each&#125;</code> block. See <a href="/guides/server-data">Server data</a> for the complete verified pattern.</p><h2 id="middleware">6. Add middleware</h2><pre><code>export default async function logger(ctx, next) &#123;
console.log(ctx.req.method, ctx.url.pathname);
return next();
&#125;</code></pre><h2 id="test-build">7. Test and ship</h2><pre><code>bun run test
bun run build
bun dist/server.js</code></pre><p>Next: <a href="/guides/deployment">deployment</a>, <a href="/guides/database">database</a>, <a href="/guides/authentication">authentication</a>, and <a href="/guides/workspaces-and-gateway">workspaces</a>.</p></article></main>
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.3.6</strong><span>Server-first documentation for the Bun-native framework.</span></p></div><nav aria-label="Footer"><a href="/access">Request access</a><a href="/license">License</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Created by <a href="https://workroot.in/">WorkRoot</a> · Private Developer Preview</p></footer>
<BackToTop />
</div>
}
}