Skip to content

Void Server Components RFC - #871

Draft
kossnocorp wants to merge 1 commit into
mainfrom
server-components
Draft

kossnocorp wants to merge 1 commit into
mainfrom
server-components

Conversation

@kossnocorp

Copy link
Copy Markdown
Contributor

This PR is a follow-up for the discussion with @cpojer in #843. It also overlaps with #731 by @yusukebe that implements Hono JSX adapter but takes different direction.

It is a proposal to add built-in Void Server Components that would allow exporting a JSX component from pages/**/*.server.tsx. The implementation is based on hono/jsx and enables server-only rendering without any client JS or even installing a view framework such as React or Vue.

// pages/about.server.tsx

export default function AboutPage() {
  return (
    <main>
      <h1>About</h1>
      <p>This is a simple page</p>
    </main>
  );
}

The body of the component becomes the loader:

// pages/weather.server.tsx

import type { CloudContext } from 'void';
import { SourceLink } from '../components/SourceLink.tsx';

export default async function WeatherPage(c: CloudContext) {
  const [location, temperature] = await fetchWeather(c.req.query('location'));

  return (
    <>
      <h1>Current weather in {location?.name || 'Unknown location'}</h1>

      <SourceLink file="pages/weather.server.tsx" />

      <form method="get" action="/weather">
        <label>
          Location{' '}
          <select name="location">
            {hubs.map(({ id, name }) => (
              <option key={id} value={id} selected={id === location?.id}>
                {name}
              </option>
            ))}
          </select>
        </label>{' '}
        <button type="submit">Show</button>
      </form>

      {typeof temperature === 'number' ? (
        <p>Temperature: {temperature} °C</p>
      ) : (
        <p>Weather data is unavailable right now.</p>
      )}

      <p>
        This async component reads the location from the URL and waits for{' '}
        <a href="https://open-meteo.com/">Open-Meteo</a> on the server.
      </p>
    </>
  );
}

But explicit loaders are also supported, so the API is consistent.

It also supports all the regular page features like layout, prerender, CSS, error pages, etc.


The idea is to provide a complete experience out-of-box and allow users build static pages before opting into using a heavier view framework.

The PR doesn't cover using islands and include client components yet. If we have an agreement on direction, we should definitely think it through how to approach it and provide great DX for people mixing server and client components without falling into the same traps as Next.js did.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://server-components-void-cloud.voidzero-docs.workers.dev (commit 469aab0)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://01772a80-void-cloud.voidzero-docs.workers.dev 469aab0 2026-11-17T23:56:19.571Z Visit the dashboard ↗

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant