graphql-ssg (version 0.4.8) is a static site generator (SSG) that specializes in bundling HTML from data feeds, particularly those powered by GraphQL. Unlike many Node.js-based SSGs, it uniquely performs bundling within a browser environment, leveraging native ESModules, URL imports, and import maps. This design choice aligns well with Web Components architectures, allowing for direct use of browser features for content generation. The project is currently in a pre-1.0 development phase, suggesting its API might evolve, but it provides a functional CLI for initializing, watching, and building projects. Key differentiators include its browser-centric bundling, automatic generation of typed GraphQL clients (via the `Chain` helper) based on configured schemas, and secure injection of configuration and environment variables into page-generating functions, preventing secret exposure. It supports both JavaScript and TypeScript page definitions for content creation.
npm install graphql-ssgVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `graphql-ssg` globally, initialize a project, configure a GraphQL schema, create a TypeScript page that fetches data using the generated `Chain` client, and then build the static HTML output.
Ensure your page files (e.g., `./pages/index.ts`) contain `export default () => html` or `export default 'Hello world';`.
Place any logic requiring `ssg.config` or `ssg.env` directly inside the `export default` function or an `export const head` function in your page files.
Install globally for convenient command-line access or ensure your `package.json` scripts correctly reference the local binary (e.g., `./node_modules/.bin/graphql-ssg`).
Pin `graphql-ssg` to an exact version (e.g., `0.4.8`) in your `package.json` to prevent unexpected breaking changes during updates, and review release notes carefully before upgrading.
Add an `export default` statement to your page file, which should return the HTML content or a function that returns it, e.g., `export default () => html`.
Move the code accessing `ssg.config` or `ssg.env` directly into the `export default` or `export const head` function to leverage the injected context.
Verify the relative import path (`../ssg/...`) matches the expected generated helper location based on your project structure and the schema name in your `graphql-ssg.json` file.
No dependency data recorded yet.