Treats

Treats

  • Getting Started

›API Reference

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

Overview

Treats provides several APIs that exposes its own modules or its wrapped packages.

Filesystem Hooks

Filesystem hooks let you inject codes to Treats internal easily. Filesystem hooks can be defined under src/_** directories. For example, to inject middleware into Treats redux store:

// src/_redux/middleware.js
import thunk from "redux-thunk";
import { logger } from "redux-logger";
export default [thunk, logger];

See Filesystem Hooks API Reference for more information.

Treats Modules

Treats provides API that exposes its own modules, these modules are usually used to better integrate your codes with Treats internal:

  1. @treats/client - Expose modules that helps you initialize/do client-side things. See Client API Reference for more information.
  2. @treats/server - Expose modules that help you initialize/do server-side things. See Server API Reference for more information.
  3. @treats/component/* - Expose components that helps integrate your codes better with Treats React internal. See Components for more information.
  4. @treats/util/* - Expose utils that Treats internally uses so you wouldn't need to implement these utilities again. See Utils for more information.

Wrapped Modules

Treats packs and wrap several packages to save you from setting up necessary packages like Redux, Apollo Client, Intl, etc and potential headache when Treats updated its dependencies. There's several packages that could be imported from Treats:

  1. @treats/graphql - Wraps react-apollo. See GraphQL API Reference for more information.
  2. @treats/redux - Wraps redux and react-redux. See Redux API Reference for more information.
  3. @treats/helmet - Wraps react-helmet. See Helmer API Reference for more information.
  4. @treats/intl - Wraps react-intl. See Intl API Reference for more information.
  5. @treats/locale-data - Wraps react-intl's locale data. To use these locale-data you could simply import @treats/locale-data/<LANGUAGE_CODE>.
  6. @treats/router - Wraps react-router-dom. See Router API Reference for more information.
← Treats with WorkboxFilesystem Hooks →
Tokopedia Open Source
Copyright © 2019 Tokopedia OSS