Golte screenshot

Golte

Author Avatar Theme by Nichady
Updated: 16 Dec 2024
238 Stars

Render Svelte components in your Go http handlers.

Categories

Overview

Goltegolte is a Go library that enables the rendering of Svelte components in Go http handlers, supporting Server-Side Rendering (SSR) and hydration capabilities without the need for NodeJS in production environments. By utilizing Goltegolte, developers can create web applications using Go while benefitting from the features of Svelte.

Features

  • SSR + Hydration: Supports Server-Side Rendering with hydration capabilities.
  • No NodeJS Required in Production: NodeJS is only required during development.
  • Layouts as Middleware: Layouts can be used as middleware and nested within each other.
  • Custom Error Pages: Provides functionality for creating customized error pages.
  • Compatibility: Works seamlessly with various routers like Go stdlib, gorilla/mux, chi, gin, echo, or any router that allows access to http.ResponseWriter and *http.Request.
  • Single Executable Compilation: Can compile to a single self-contained executable for ease of deployment.

Installation

To install Goltegolte, first ensure that Go and NodeJS are installed. Then set {“type”: “module”} in the package.json file. After initialization of go.mod and package.json, install Goltegolte by running npx golte. By default, Goltegolte will use the web/app.html template file and search for .svelte files in the web/ directory. Each .svelte file can be rendered in Go code using the filename relative to the source directory (web/), without the file extension.

Summary

Goltegolte is a versatile Go library that bridges the gap between Go and Svelte by facilitating SSR and hydration features. By simplifying the integration of Svelte components in Go applications, Goltegolte offers developers a seamless way to leverage the power of both technologies within a single executable. With easy installation steps and streamlined configuration options, Goltegolte streamlines the development process for creating dynamic web applications.