.gio/
The working directory GioJS writes in the project root: client bundles, stylesheets, caches, fonts and the generated route types.
.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
| Path | Written by | Override |
|---|---|---|
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.ts | The worker at every start, and gio typegen | - |
ipc-*.sock, ws-*.sock | The 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:
/// <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
{
"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"]
}.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 --noEmitpnpm exec gio typegen
pnpm exec tsc --noEmityarn gio typegen
yarn tsc --noEmitbunx gio typegen
bunx tsc --noEmitGood 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/orpublic/: 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 ownGIO_CACHE_DIRif they must not share cached pages. - A standalone build folder has its own layout (
static/,worker.js, a.gio/manifest.json); see Standalone.
Related
- TypeScript - typed routes.
gio typegen,gio routes- Caching Layers, Environment variables
Version history
| Version | Changes |
|---|---|
v0.1.0-beta.8 | routes.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.6 | routes.d.ts is generated at every start. |
v0.1.0-beta.5 | Client bundles are built into build/static/chunks/. |