Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render renders an Inertia page. Use in handlers to return Vue/React/Svelte component data. When the request has the X-Inertia header, returns JSON. Otherwise returns full HTML with the root template.
func (c *HomeController) Index(ctx *http.Context) error {
users := loadUsers()
return inertia.Render(ctx, "Home/Index", map[string]any{
"users": users,
})
}
Types ¶
type Config ¶
type Config struct {
// URL is the application URL (e.g. "http://localhost:3000").
// Used for redirects and asset URLs.
URL string
// RootTemplate is the path to the root HTML template.
// Must contain a div with id="app" and data-page="{{ marshal .page }}".
// Example: "resources/views/app.html"
// If empty and TemplateFS is nil, uses the embedded default.
RootTemplate string
// TemplateFS is an optional embed.FS for the root template.
// When set, RootTemplate is relative to this filesystem.
TemplateFS fs.FS
// Version is the asset version for cache busting.
// Change this when assets change to force client reload.
Version string
// SSRURL is the optional Server-Side Rendering Node server URL.
// When set, Inertia will use SSR for initial page load.
SSRURL string
}
Config holds Inertia.js plugin configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for development.
type Manager ¶
type Manager interface {
// Middleware returns http middleware that wraps the given handler.
Middleware(next interface{}) interface{}
// Render writes an Inertia page response to the response writer.
Render(w interface{}, r interface{}, component string, props map[string]any) error
Share(key string, value any)
}
Manager is the Inertia adapter interface. Implementations wrap github.com/petaki/inertia-go or similar adapters.
Click to show internal directories.
Click to hide internal directories.