Skip to content

GuyARoss/orbit

Repository files navigation

Orbit · prerelease codecov CodeFactor GitHub license

Orbit is a golang server side processing framework for building server side web applications.

  • Micro-frontend: Out of the box support for React and vanilla JavaScript micro frontends.
  • Static bundling: Automatically creates static HTML files for components that don't make use of server side processing.
  • Bundling support: Orbit currently has support for the following tools:
Name Extent of support
Vanilla Javascript Full support
Client side React Full support
Server side React Experimental
Vue Planned

Installation

  • Go Install: To install with go install, you can use the command go install github.com/GuyARoss/orbit@latest
  • Manual Installation: To install manually, clone this repo and compile it with go build.

Examples

There are several examples that exist in the ./examples. Here is a basic one to get you up and running.

  1. Initialize the workspace directory with orbit init, then follow the prompts
  2. Create a react component
// /pages/hello-world.jsx
const HelloWorldComponent = ({ from }) => {
    return (
        <>
            <div> Hello, from {from} </div>
        </>
    )
}

export default HelloWorldComponent
  1. Run the build process with orbit build
  2. Create golang application
// main.go
package main

import (
    // ... 
)

func main() {
    // orbitgen comes from an autogenerated lib output from orbit
    orb, err := orbitgen.New()
    if err != nil {
        panic(err)
    }

    orb.HandleFunc("/", func (r *orbitgen.Request) {
        props := make(map[string]interface{})
        // sets the prop 'from' to the string 'orbit'
        props["from"] = "orbit"

        // renders a single page & passes props into the component
        c.RenderPage(orbitgen.HelloWorldComponent, props)

        // can also use c.RenderPages(...) to build a micro-frontend
    })

    http.ListenAndServe(":3030", orb.Serve())
}
  1. Run golang application with go run main.go

Contributing

Please first read our contributing guide before contributing to this project.

To gain exposure to the project you can find a list of good first issues.

License

Orbit it licensed under GNU GPLv3