Treats

Treats

  • Getting Started

›Main Concepts

Getting Started

  • Installation

Tutorial

  • 01. Creating Your First Page
  • 02. Using Redux
  • 03. Using GraphQL
  • 04. Fetch Data for SSR
  • 05. Adding Addons

Main Concepts

  • Overview
  • Routing
  • Localization
  • Code-splitting
  • Redux
  • GraphQL Client
  • Middlewares
  • Helpers
  • Server-side Events
  • Server-side Template
  • Server-side Rendering
  • Custom Server App
  • Custom Client Initialization
  • Custom React App
  • Runtime Config
  • Build Config
  • Environment Variables
  • Code Generator
  • Scripts
  • Addons
  • Typescript
  • Workbox

API Reference

  • Overview
  • Filesystem Hooks
  • Components
  • Server
  • Client
  • Router
  • Intl
  • Locale Data
  • Helmet
  • Redux
  • Graphql

Authoring Addons

  • Overview
  • Helpers
  • Middlewares
  • Generators
  • Wrapping Up

Addons

  • Treats Addons List

Contributing

  • How To Contribute

FAQ

  • FAQs

Custom Client Initialization

You can also provide src/_client/index.js filesystem hooks, this file would act as the entry point for our client-side code. We provide a initClient wrapper function that could be imported from @treats/client.

// src/_client/index.js
import initClient from "@treats/client";

const app = initClient();

export default app;

With custom client initialization we could manage how our client-side app will receive server supplied states and do any other global variable initialization that our client-side codes might need.

Supplying Server States

Similar to initServer function, initClient could also be supplied a configuration object with the following fields:

  1. reduxState - Used to supply Redux state that would be used to rehydrate client-side Redux store.
  2. apolloState - Used to supply Apollo state that would be used to rehydrate client-side Apollo in-memory-cache.
  3. lang - Used to supply language that the apps are currently initialized with.
  4. rootDiv - Used to supply id of React root element.
  5. appProps - Used to supply additional props that needs to be supplied to our React app.
← Custom Server AppCustom React App →
Tokopedia Open Source
Copyright © 2019 Tokopedia OSS