@knyt/glazier
v0.4.0
Published
A Bun plugin for server-side rendering and static site generation with built-in hydration for web components.
Downloads
9
Maintainers
Readme
🧊 A Bun plugin for server-side rendering and static site generation with built-in hydration for web components.
This package is part of Knyt, a toolkit designed to simplify modern web development.
Key benefits
- Write HTML, not templates – Compose pages with standard HTML, no custom syntax
- Built for Bun’s ecosystem – Leverages native tooling and module resolution
- Your rendering, your rules – Mix SSG, SSR, and hydration with ease
- Web Components, zero config – Auto-detects components, renders open/closed shadow roots, requiring no wrapper logic *
- Extensible content support – Built-in recognition for MDX, frontmatter, and table of contents **
- Extend without friction – Middleware and plugin system for custom logic
* Closed shadow roots are rendered by implementing a simple interface, without exposing the shadow root. ** Add MDX features by installing plugins – the integration points are built in.
Try in GitHub Codespaces
You can try Knyt Glazier in your browser using GitHub Codespaces. The pre-configured devcontainers can be used to explore Knyt's server-side capabilities without needing to set up a local environment.
Key Features
HTML composition
- Composition using standard HTML tags - no custom templating syntax required
- Slot-based content interpolation for flexible layouts
- Native support for including and rendering Web Components/Views
Request-driven architecture for dynamic data injection
SSG & SSR
- Full static site generation for component-based HTML pages
- Complete server-side rendering for dynamic pages
- Partial HTML snippet rendering (htmx-compatible)
- Web Component hydration via Knyt Luthier
- Extensible through middleware with utilities for request data association/overrides
Batteries-included
- Built-in MDX and Web Component recognition
- Automatic frontmatter and table-of-contents extraction from MDX
- Optional file-based routing (document path to route conversion)
- Route-aware asset handling via Bun's static bundler
- Knyt Live Mode for development with hot reloading
Dependency management
- Automatic dependency resolution, bundling and injection
- Progressive, non-blocking hydration strategy
- Memory-efficient virtual module system (no filesystem clutter)
- Seamless Bun integration: Leverages Bun's native toolchain and module system
Documentation
Documentation is available at knyt.dev, including guides for:
Usage
To include an HTML snippet you can use the <knyt-include> tag:
<!doctype html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<!-- Include an HTML snippet -->
<knyt-include src="./body-content.html"></knyt-include>
</body>
</html>Then, run the Bun server:
NODE_ENV=production bun index.htmlInstall
First, ensure you have Bun installed (v1.2.21 or later).
Then, install the package using Bun:
bun add @knyt/glazierThen, add the plugin to your bunfig.toml file:
preload = ["@knyt/glazier/preload"]
[serve.static]
plugins = ["@knyt/glazier/plugin"]Now you can use the plugin in your HTML files.
Updates
See the CHANGELOG for a list of changes.
License
This package is licensed under the BSD 3-Clause License.
Open-Source Initiative
This project is supported by Sables Applications LLC as part of its open-source initiatives.
