百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

go-react-ssr

> 前端框架
开源

使用 Go 和 React 构建全栈 Web 应用程序。端到端的类型安全性和极快的速度 ⚡️

185 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

使用 Go 和 React 构建全栈 Web 应用程序。端到端的类型安全性和极快的速度 ⚡️


Go-SSR is a drop in plugin to any existing Go web framework to allow server rendering React. It's powered by esbuild and allows for passing props from Go to React with type safety.

Go-SSR was developed due to a lack of an existing product in the Go ecosystem that made it easy to build full-stack React apps. At the time, most Go web app projects were either built with a static React frontend with lots of client-side logic or html templates. I envisioned creating a new solution that would allow you to create full-stack Go apps with React but with logic being moved to the server and being able to pass that logic down with type-safe props. This project was inspired by Remix and Next.JS, but aims to be a plugin and not a framework.

Features

  • Lightning fast compiling
  • Auto generated Typescript structs for props
  • Hot reloading
  • Simple error reporting
  • Production optimized
  • Drop in to any existing Go web server

️ Getting Started

Go-SSR was designed with the idea of being dead simple to install. Below are 2 easy ways of setting it up:

⚡️ Using the CLI tool

The easiest way to get a project up and running is by using the command line tool. Install it with the following command

bash
$ go install github.com/natewong1313/go-react-ssr/gossr-cli@latest

Then you can call the following command to create a project

bash
$ gossr-cli create

You'll be prompted the path to place the project, what web framework you want to use, and whether or not you want to use Tailwind

Add to existing web server

To add Go-SSR to an existing Go web server, take a look at the examples folder to get an idea of what a project looks like. In general, you'll want to follow these commands:

bash
$ go get -u github.com/natewong1313/go-react-ssr

Then, add imports into your main file

go
import (
	...
	gossr "github.com/natewong1313/go-react-ssr"
)

In your main function, initialize the plugin. Create a folder for your structs that hold your props to go, which is called models in the below example. You'll also want to create a folder for your React code (called frontend in this example) inside your project and specifiy the paths in the config. You may want to clone the example folder and use that.

go
engine, err := gossr.New(gossr.Config{
    AssetRoute:         "/assets",
    FrontendDir:        "./frontend/src",
    GeneratedTypesPath: "./frontend/src/generated.d.ts",
    PropsStructsPath:   "./models/props.go",
})

Once the plugin has been initialized, you can call the engine.RenderRoute function to compile your React file to a string

go
g.GET("/", func(c *gin.Context) {
	renderedResponse := engine.RenderRoute(gossr.RenderConfig{
		File:  "Home.tsx", 
		Title: "Example app", 
		MetaTags: map[string]string{
			"og:title":    "Example app", 
			"description": "Hello world!",
		}, 
		Props: &models.IndexRouteProps{
			InitialCount: rand.Intn(100),
		},
	})
	c.Writer.Write(renderedResponse)
})

Deploying to production

All of the examples come with a Dockerfile that you can use to deploy to production. You can also use the gossr-cli to create a project with a Dockerfile. Below is an example Dockerfile

…

Go SSR has been tested and deployed on the following platforms:

  • Fly.io - example app
  • Render - example app
  • Hop.io - example app

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogolangreactjstypescript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架