Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
docs
.vitepress
!.vitepress/config.mts
113 changes: 113 additions & 0 deletions docs/guide/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
prev:
text: 'Usage'
link: '/guide/usage'

next: false
---

# 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

::: tip 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 →](https://github.com/olivere/vite/tree/main/examples/helper-function-basic)

## Basic with Handler

::: tip 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 →](https://github.com/olivere/vite/tree/main/examples/basic)


## Multi-Page Application

::: tip 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 →](https://github.com/olivere/vite/tree/main/examples/multi-page-app)



## Multiple Vite Instances Application

::: tip 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 →](https://github.com/olivere/vite/tree/main/examples/multiple-vite-apps)

## Template Registration

::: tip 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 →](https://github.com/olivere/vite/tree/main/examples/template-registry)

## Inertia.js Integration

::: warning 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 →](https://github.com/danclaytondev/go-inertia-vite)


## Router Application

::: warning 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 →](https://github.com/olivere/vite/tree/main/examples/router)
61 changes: 61 additions & 0 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
next:
text: 'Usage'
link: '/guide/usage'
---

# Go-Vite Integration

This library helps you integrate a Vite frontend with a Go backend by following the [official Vite backend integration guide](https://vitejs.dev/guide/backend-integration.html).


## Overview

This library offers two approaches:

1. **Helper Function** - Generate HTML tags to link to your Vite assets
2. **HTTP Handler** - A complete `http.Handler` to serve your Vite application

## Prerequisites

Before using this library, ensure your Vite frontend is configured correctly:
::: warning IMPORTANT
- Follow the [Vite backend integration guidelines](https://vitejs.dev/guide/backend-integration.html) to configure your `vite.config.(js|ts)` file to generate the `manifest.json` for production.
:::


## Quick Start

```bash
$ go get github.com/olivere/vite
```


## Supported frameworks
This library works with all major Vite-supported frontend frameworks:
- React (with TypeScript and SWC options)
- Vue
- Vanilla JS/TS
- Preact
- Lit
- Svelte
- Solid
- Qwik


## Usage

- [Helper Function](/guide/usage#option-1-helper-function)
- [HTTP Handler](/guide/usage#option-2-http-handler)
- [Configuration](/guide/usage#configuration-options)



## Examples

See the [examples](/guide/examples) page.

## License

This project is licensed under the terms specified in the [LICENSE](https://raw.githubusercontent.com/olivere/vite/refs/heads/main/LICENSE) file.

Loading