Code Monkey home page Code Monkey logo

go-react-example's Introduction

go-react-example

This is an example of project which shows how to render React app on Golang server-side.
It's very similar to andreypopp/react-quickstart(please see it first) project, but with some Go and other benefits.

What it contains?

  • go-duktape bindings for a thin, embeddable javascript engine
  • gin framework
  • staticbin middleware for gin, to serve embedded static files
  • config package, to define config, parse flags and environment variables
  • [optional] live code reloading, by fswatch, avilable for OSX and linux

Benefits

First of all and most important, rendering is fully synchronous. There is no need to use react-async. Because on the server side the code executes in synchronous mode. This is duktape specific. Also, there is a binding between superagent javascript package and golang server side function. That means that you do http request and it is processed by golang function. As a consequence, there is no need to do real http request from the server to the same. Now it works between your react application and server side application directly. And it is possible to process requests with user session as well.

Also this project allows you to embed all static files. So, you have one executable file of you application.

Install

$ git clone https://github.com/olebedev/go-react-example
$ cd go-react-example
$ go get ./...
$ go get -u github.com/jteeuwen/go-bindata/...
$ npm i

Now you ready to start.

$ make
$ go run *.go

If you have fswatch, you can type this make serve and project will be reloaded every time when you change any of *.go or static/* files.
fswatch is avilable for OSX and linux.

go-react-example's People

Contributors

olebedev avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.