view

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package view provides Vite backend integration for fiber.

It generates the correct <script>/<link> tags for the HTML <head> section without serving index.html itself — the Go server owns the HTML shell.

Dev mode: tags point to the Vite dev server (HMR + hot reload). Prod mode: tags use content-hashed filenames read from dist/.vite/manifest.json.

Vite backend integration reference: https://vite.dev/guide/backend-integration.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type View

type View struct {
	// contains filtered or unexported fields
}

View wraps olivere/vite.Fragment and exposes fiber-friendly helpers.

func New

func New(isDev bool) (*View, error)

New builds a View. isDev comes from AppConfig.IsDev().

  • Dev: generates @vite/client + entry script tags for the Vite dev server.
  • Prod: reads dist/.vite/manifest.json and generates hashed asset tags.

func (*View) IndexHandler

func (v *View) IndexHandler(c fiber.Ctx) error

IndexHandler serves the SPA shell page for every unmatched route.

app.Get("/*", viteView.IndexHandler)

func (*View) IsDev

func (v *View) IsDev() bool

IsDev reports whether the view is in development mode.

func (*View) Tags

func (v *View) Tags() template.HTML

Tags returns the HTML tags to inject inside <head>. Pre-escaped as template.HTML — safe for Go templates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL