GioJSdocs
On this page

.gio/

The working directory GioJS writes in the project root: client bundles, stylesheets, caches, fonts and the generated route types.

text
.gio/
  build/
    manifest.json        what the last build produced
    entries/             generated hydration entry files
    css-entries/         generated stylesheet entry files
    static/chunks/       client bundles        -> /_next/static/chunks/
    static/css/          route stylesheets     -> /_next/static/css/
  cache/
    pages/               the page cache's disk tier
    images/              optimized images
  fonts/                 [[fonts]] files and fonts.css -> /_gio/fonts/
  routes.d.ts            route types
  css-modules.d.ts       types for CSS imports
  ipc-<id>.sock          worker sockets (Unix)

Reference

PathWritten byOverride
build/The worker at every start (in a pool, the first worker; the others reuse it)GIO_STATIC_DIR changes the directory the server serves /_next/static/ from (default .gio/build/static)
cache/pages/The server, for every cached page[cache] disk_path, GIO_CACHE_DIR
cache/images/The image optimizer (/_gio/image)GIO_IMAGE_CACHE_DIR
fonts/The server at every start, from [[fonts]]GIO_FONTS_DIR
routes.d.ts, css-modules.d.tsThe worker at every start, and gio typegen-
ipc-*.sock, ws-*.sockThe server, per instance (Unix only; Windows uses named pipes)GIO_SOCKET_PATH, GIO_WS_SOCKET_PATH
export/gio export, for its generated entry files-

The directory is created in the project root (the parent of app/). The socket files are the exception: they go in the .gio/ of the directory the server was started in, normally the same one.

routes.d.ts

Declares every page and route.ts pattern with its params in the global GioJS.RegisteredRoutes interface. href(), useParams(), PageProps, GetServerSideProps, RouteHandler and the other route-typed helpers read it, so a pattern that is not one of your routes fails tsc:

.gio/routes.d.ts
/// <reference path="./css-modules.d.ts" />
declare global {
  namespace GioJS {
    interface RegisteredRoutes {
      '/': Record<string, never>;
      '/blog/:slug': { slug: string };
      '/docs/*slug': { slug: string };
      '/shop/*path?': { path?: string };
    }
  }
}
export {};

css-modules.d.ts

Types import styles from './x.module.css' as a map of class names to strings, and lets plain .css imports through. routes.d.ts references it, so including one includes both.

Examples

tsconfig.json and .gitignore

tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "lib": ["ES2022", "DOM"],
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "noEmit": true,
    "jsx": "react-jsx",
    "strict": true
  },
  "include": ["app", "components", "lib", ".gio/routes.d.ts"]
}
.gitignore
.gio/

Projects made with create-giojs have both already.

Types in CI

On a fresh checkout the type files do not exist until the server has started once. Write them without a server before tsc:

npx gio typegen
npx tsc --noEmit

Good to know

  • Everything in .gio/ is regenerated, so never commit or edit it. Deleting it while the server is stopped is safe; you lose the page and image caches.
  • The dev watcher ignores .gio/, so the files GioJS writes never restart the worker.
  • The page cache directory may not be, contain or sit inside app/ or public/: startup refuses such a [cache] disk_path.
  • Two servers started from the same project share .gio/: the build, the caches and the type files. Give each its own GIO_CACHE_DIR if they must not share cached pages.
  • A standalone build folder has its own layout (static/, worker.js, a .gio/manifest.json); see Standalone.

Version history

VersionChanges
v0.1.0-beta.8routes.d.ts fills the global GioJS.RegisteredRoutes registry; css-modules.d.ts; route stylesheets in build/static/css/; gio typegen writes the types without a server.
v0.1.0-beta.6routes.d.ts is generated at every start.
v0.1.0-beta.5Client bundles are built into build/static/chunks/.