# @mizchi/ssr-helpers

> Implement `react-cache` SSR helpers.

Latest version **0.0.1** (published 2019-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mizchi/ssr-helpers
pnpm add @mizchi/ssr-helpers
yarn add @mizchi/ssr-helpers
bun add @mizchi/ssr-helpers
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-04-03 |
| First published | 2019-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mizchi |

## Links

- npm: https://www.npmjs.com/package/@mizchi/ssr-helpers
- npm.io page: https://npm.io/package/@mizchi/ssr-helpers

## Recent versions

- 0.0.1 (latest) — 2019-04-03

## README

# @mizchi/ssr-helpers

Implement `react-cache` SSR helpers.

## Requirements

- react: ^16.7
- react-dom: ^16.7
- regenerator-runtime(included babel-polyfill)

## Data fetcher

```tsx
import { renderAsync, createResource } from "@mizchi/ssr-helpers";

// data fetcher
const resource = createResource(async () => {
  await new Promise(r => setTimeout(r, 1000));
  return { message: "hello" };
});

function App() {
  const data = resource.read();
  return <div>{data.message}</div>;
}

const html = await renderAsync({
  tree: <App />
});
```

Client rendering

```tsx
import React from "react";
import ReactDOM from "react-dom";

const root = document.querySelector(".root") as HTMLDivElement;
ReactDOM.hydrate(
  <Suspense fallback="loading">
    <App />
  </Suspense>,
  root
);
```

## How to dev

- `yarn dev`: Start application server on `http://localhost:1234`
- `yarn build`: Generate `dist`
- `yarn test`: Run jest
- `yarn deploy`: Deploy to netlify (need netlify account)

## LICENSE

MIT

---
_Source: https://npm.io/package/@mizchi/ssr-helpers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
