Documentation
¶
Overview ¶
Package reactssr provides Server Side Rendering capabilties for React applications.
Example (NewServerSideRenderer) ¶
package main
import (
"fmt"
"regexp"
"github.com/tmc/reactssr"
)
func main() {
r, err := reactssr.NewServerSideRenderer("./testdata/test-app-1/build/out.js")
if err != nil {
panic(err)
}
output, err := r.Render()
if err != nil {
panic(err)
}
untilFirstImage := regexp.MustCompile(`^(.*)<img`).FindAllString(output, -1)
fmt.Println(untilFirstImage[0])
// This is the expected output from a vanilla create-react-app app:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
Path string
// contains filtered or unexported fields
}
Renderer renders a React application to HTML.
func NewServerSideRenderer ¶
NewServerSideRenderer creates a new server side renderer from a JavaScript bundle file.
Click to show internal directories.
Click to hide internal directories.