egg-frost

0.1.0 • Public • Published
Status: still in development. Please do not use in production environment

egg-frost

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Inspired by tokenfoundry koa-react-ssr.

Install

$ npm i egg-frost --save

Usage

// {app_root}/config/plugin.js
exports.frost = {
  enable: true,
  package: 'egg-frost',
};

Configuration

// {app_root}/config/config.default.js
exports.frost = {
  client: {
    /* This is used to start next.js server in dev mode or production mode. [Default: dev mode] */
    env: ''
  },
};

see config/config.default.js for more detail.

Pages

Folder Structure
- [root-dir]
- pages
  - Home.js
  - ...
  - ...
  - ...
Sample page
// Home.js
import React from 'react';
import Head from 'next/head';
 
export function withSSR() {
    return function adapter(ScreenComponent) {
        // eslint-disable-next-line no-param-reassign
        ScreenComponent.getInitialProps = function getInitialProps({ query }) {
            return query;
        };
        return ScreenComponent;
    };
}
 
class HomeScreen extends React.PureComponent {
  render() {
    return (
      <div>
        <Head>
          <title>My Page</title>
        </Head>
        <h1>Hi pg!</h1>
      </div>
    )
  }
}
 
export default withSSR()(HomeScreen);

TODO

  • Write Tests
  • Update Documentation

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-frost

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

9.04 kB

Total Files

19

Last publish

Collaborators

  • akshaysingh