Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
AppEnv string // "production" or "development"
AssetRoute string // The route to serve assets from, e.g. "/assets"
FrontendDir string // The path to the frontend folder, where your React app lives
GeneratedTypesPath string // The path to the generated types file
PropsStructsPath string // The path to the Go structs file(s), comma-separated for multiple files
LayoutFilePath string // The path to the layout file, relative to the frontend dir
LayoutCSSFilePath string // The path to the layout css file, relative to the frontend dir
TailwindConfigPath string // The path to the tailwind config file
HotReloadServerPort int // The port to run the hot reload server on, 3001 by default
JSRuntimePoolSize int // The number of JS runtimes to keep in the pool, 10 by default
CacheConfig cache.CacheConfig // Cache configuration (local or redis)
ClientAppPath string // Path to client SPA app (e.g., "App.tsx") for client-side routing after hydration
// SPA hydration mode options (only used when ClientAppPath is set):
// - "router": wraps with StaticRouter/BrowserRouter for true hydration (default, requires react-router-dom)
// - "replace": uses createRoot to replace SSR HTML (no hydration, compatible with any SPA structure)
SPAHydrationMode string // "router" or "replace", defaults to "router"
// External JS file options (for browser caching optimization):
// When StaticJSDir is set, JS bundles are written to files instead of inlined in HTML.
// This enables browser caching - the React library bundle rarely changes and can be cached.
StaticJSDir string // Directory to write JS files (e.g., "frontend/dist/assets"). If empty, JS is inlined.
IsDev bool // Development mode - enables hot reload, disables caching
// Generators are custom code generators that run during engine initialization (dev mode only)
// Use this to generate routes, API clients, or any other code based on the SSR configuration
Generators []Generator
}
Config is the config for starting the engine
type Engine ¶
type Engine struct {
Logger *slog.Logger
Config *Config
HotReload *HotReload
Cache cache.Cache
RuntimePool *jsruntime.Pool
CachedLayoutCSSFilePath string
CachedClientSPAJS string // Cached client SPA bundle JS
CachedServerSPAJS string // Cached server SPA bundle JS (for StaticRouter rendering)
CachedServerSPACSS string // Cached server SPA bundle CSS
}
func (*Engine) BuildLayoutCSSFile ¶
BuildLayoutCSSFile builds the layout css file if it exists
func (*Engine) IsProduction ¶
IsProduction returns true if running in production mode
func (*Engine) RenderRoute ¶
func (engine *Engine) RenderRoute(renderConfig RenderConfig) []byte
RenderRoute renders a route to html
type Generator ¶ added in v1.0.4
type Generator interface {
// Generate is called during engine initialization (dev mode only)
// config contains all SSR configuration including props paths
Generate(config *Config) error
}
Generator interface for custom code generation Implementations can generate routes, API clients, or any other code based on the SSR configuration
Source Files
¶
Click to show internal directories.
Click to hide internal directories.