Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 39 ยท SolidStart and Routing

SolidStart Overview

Meet SolidStart, the full-stack framework for SolidJS: project layout, server rendering and streaming, rendering modes, deployment presets and how it differs from plain Solid.

Plain Solid, which you have used so far, is a UI library: it renders components in the browser. A real product also needs routing, server rendering for fast first paint and search engines, a way to talk to a database, and a build that deploys somewhere. SolidStart is the official full-stack framework that bundles those pieces around Solid, in the same way Next.js does for React and Nuxt does for Vue.

This chapter explains how SolidStart is organized, how routing works, how to load data and how to run code on the server.

SolidStart needs Node.js, a build tool and often a server, none of which exist inside this site's live editors. Project files are therefore shown read-only, and the live examples are small stand-ins that reproduce the idea (for example, streaming) with plain Solid. Each stand-in is labelled. Framework APIs and file names change between releases, so confirm details against the official SolidStart documentation for the version you install.

Creating a project

You create a project with the Solid scaffolder and run it with a dev server:

Terminal
npm create solid@latest my-app     # choose "SolidStart", then a template
cd my-app
npm install
npm run dev                        # http://localhost:3000

The generator asks whether you want TypeScript and which starter to use (a bare app, with a router, with tests, and so on). Choose TypeScript: the types for routes, queries and server functions are a large part of the experience.

Project layout

A fresh project looks roughly like this:

Text
my-app/
  app.config.ts          # framework and build configuration
  src/
    app.tsx              # the root component: layout and router
    entry-client.tsx     # starts the app in the browser (hydration)
    entry-server.tsx     # server entry: document shell and HTML
    routes/
      index.tsx          # the page at /
      about.tsx          # the page at /about
      blog/[slug].tsx    # a dynamic page at /blog/anything
      api/hello.ts       # an API endpoint at /api/hello
  public/                # static files served as they are

Everything under src/routes becomes a URL (see file-based routing). app.tsx holds what stays the same across pages, such as navigation, and mounts the router. A minimal one looks like this:

TSX
// src/app.tsx
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start/router";
import { Suspense } from "solid-js";

export default function App() {
  return (
    <Router root={(props) => (
      <>
        <nav><a href="/">Home</a> <a href="/about">About</a></nav>
        <Suspense>{props.children}</Suspense>
      </>
    )}>
      <FileRoutes />
    </Router>
  );
}

FileRoutes generates the route table from the files in src/routes, and props.children is the current page.

Server rendering and hydration

With plain Solid, the browser downloads JavaScript, runs it, and only then shows content. SolidStart can instead render your components to HTML on the server. The visitor sees content immediately, and search engines read real HTML. Then the browser loads the JavaScript and hydrates the page: Solid attaches its reactive effects to the existing DOM instead of rebuilding it.

sequenceDiagram
  participant B as Browser
  participant S as Server
  B->>S: GET /products
  S->>S: Render components to HTML
  S-->>B: HTML (visible at once)
  B->>S: Request JS bundle
  B->>B: Hydrate: attach effects to the DOM

The page is visible after the first response. Hydration makes it interactive.

Streaming

Waiting for the slowest query before sending anything would waste the benefit. SolidStart supports streaming: the server sends the HTML shell right away, with Suspense fallbacks in place of slow parts, and sends each part later as its data becomes ready. The browser swaps the fallback for the finished content without any client request.

The stand-in below reproduces the visible effect on the client: a page shell appears at once and the sections fill in as their data arrives. (A real server streams HTML; here a timer plays the role of the slow database.)

Stand-in: a page that fills in as data arrives

Rendering modes

SolidStart lets you choose per app how pages are produced:

Mode What happens Good for
SSR (default) HTML is rendered on each request, then hydrated Dynamic pages, SEO, personalised content
Streaming SSR Same, but the HTML arrives in pieces behind Suspense Pages with slow data
SPA (ssr: false) Only a shell is served; everything renders in the browser Dashboards behind a login
Prerendering Selected routes are rendered to static HTML at build time Marketing pages, docs, blogs

You set these in app.config.ts:

TypeScript
import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  ssr: true,                                  // set false for a pure SPA
  server: {
    preset: "node-server",                    // see deployment below
    prerender: { routes: ["/", "/about"] },   // static HTML at build time
  },
});

Deployment presets

SolidStart's server layer builds on Nitro, so the same app can be packaged for different hosts by choosing a preset: a Node server, serverless functions (Vercel, Netlify), edge runtimes (Cloudflare), or a fully static site. You change one line in the config and the build output changes shape; your routes and components do not.

What SolidStart adds to Solid

  • File-based routing and nested layouts.
  • Server functions ("use server") and API routes, so one codebase holds front end and back end.
  • Data loading with the router's query and createAsync, wired to SSR and streaming.
  • Forms and actions that work with and without JavaScript.
  • Middleware and server-only environment access (secrets never reach the browser).

You still write the same components, signals and stores. Fine-grained reactivity works identically on the server and in the browser; the main difference is that code which touches the DOM (window, document) must run only in the browser, for example inside onMount or createEffect, which never run on the server.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is hydration?

    The server sends real HTML; the browser then wires Solid's effects to that DOM instead of rebuilding it.
  2. 2. Which directory holds the pages of a SolidStart app?

    Files under src/routes become URLs, and FileRoutes builds the route table from them.
  3. 3. What does streaming SSR let the server do?

    Fallbacks are sent immediately and each section is delivered when its data is ready.
  4. 4. Where should code that uses window or document run in SolidStart?

    Those globals do not exist on the server; onMount and effects are skipped there.

Summary

  • SolidStart is the full-stack framework for Solid: routing, SSR, streaming, server functions and deployment presets.
  • src/routes defines pages, src/app.tsx the shared shell, app.config.ts the build and rendering options.
  • SSR gives fast first paint and SEO; hydration makes the HTML interactive; streaming sends slow parts later.
  • Choose SSR, SPA or prerendering to fit each app, and a preset to fit the host.
  • Browser-only code belongs in onMount or effects.

Next: File-Based Routing