Skip to content

Examples

This section provides various examples demonstrating how to use this library with different setups. Each example can be quickly tried using the npx degit command provided.

Simple Helper Function

Minimal Setup

A minimal React app with Go backend integration using basic helper functions.

bash
$ npx degit olivere/vite/examples/helper-function-basic my-helper-app
$ cd my-helper-app
# Follow setup instructions in the example README

View code →

Basic with Handler

Standard Approach

Demonstrates a basic React app with Go backend using the standard handler approach.

bash
$ npx degit olivere/vite/examples/basic my-basic-app
$ cd my-basic-app
# Follow setup instructions in the example README

View code →

Multi-Page Application

Multiple Entry Points

For Vite apps with multiple entry points, demonstrating how to create separate handlers with the ViteEntry field.

bash
$ npx degit olivere/vite/examples/multi-page-app my-multi-page-app
$ cd my-multi-page-app
# Follow setup instructions in the example README

View code →

Multiple Vite Instances Application

Multiple Vite instances

For Apps where you need to manage different vite instances, like admin panel(Vite + ReactTS) and main app (Vite + Vue)

bash
$ npx degit olivere/vite/examples/multiple-vite-apps multiple-vite-apps
$ cd my-multi-page-app
# Follow setup instructions in the example README

View code →

Template Registration

Custom Templates

Shows how to use custom HTML templates in your Go backend for serving different React pages.

bash
$ npx degit olivere/vite/examples/template-registry my-template-app
$ cd my-template-app
# Follow setup instructions in the example README

View code →

Inertia.js Integration

Third-Party Integration

Example of using Golang with net/http, Inertia.js and this library for managing Vite assets.

bash
$ npx degit danclaytondev/go-inertia-vite my-inertia-app
$ cd my-inertia-app
# Follow setup instructions in the example README

View code →

Router Application

Advanced Implementation

A more complex application with a Go backend serving a Vite-based app using TanStack Router and TanStack Query libraries.

bash
$ npx degit olivere/vite/examples/router my-router-app
$ cd my-router-app
# Follow setup instructions in the example README

View code →