Skip to content

ryardley/drator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Drator

Simple API for sending data from the server to the client mainly so I can get used to publishing to npm.

Usage

Simple data sharing

The idea is to send structured data on the rendered HTML page to your clientside code without the need for asynchronous API calls. This is done so that your clientside code can pick up the state of the app as constructed by the server and continue to serve user interations.

To send a message

// server.js
import {dehydrate} from 'drator';

const markup = dehydrate('App', {simple: 'object'});

// 'window.App={"simple":"object"}'

To recieve a message

// client.js
import {hydrate} from 'drator';

const data = hydrate('App');

data.simple; // 'object'

About

A simple API for sending data from the server to the client in the context of an isomorphic app.

Resources

Stars

Watchers

Forks

Packages

No packages published