Socket
Book a DemoInstallSign in
Socket

mikasa

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mikasa

Framework for rendering react server-side

0.2.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Documentation is outdated, will update it soon.

Demo

A simple demo of mikasa using iTunes Api: Demo

mikasa

A simple wrapper for server side rendering isomorphic react. It uses Koa.js as webserver, Redux and React-router for routing.

Configuration

ParametersTypeDescription
portNumberThe port that webserver will run on
routesArrayAn Array of Route Objects
staticObjectAn configuration object
layoutReact ComponentThe React Component that will be used as layout
storeObjectAn Object containing the redux reducer and the initialState
promisesArrayAn array of promises that need to be resolved before any render from server side

Routes

Routes are based on routes from react-router, they must be specified as an array of objects that must contain the following attributes.

ParametersTypeDescription
pathStringThe route path, for example: /about
exactBooleanExact parameter from react-router
componentReact ComponentThe component that will be rendered for that route
loadDataFunctionA function used for doing asynchronus actions before the render of the component. It must return a promise or an array of promises. The function takes three parameters: The context parameter from koa that contains the request, a shared object, and the redux store object for the dispatches before the render.

Static

The static object must contain the following attributes.

ParametersTypeDescription
pathStringThe path that will be used in browser, for exmaple: /public
localStringThe path to folder containing the static files.
optionsObjectThis object is used as options for koa-static. example: { gzip: true }

Store

The store object is used to create the redux storage on the backend. It must contain the following attributes:

ParametersTypeDescription
reducerFunctionIt can be a simple reducer or a combined reducer.
initialStateObjectThis will be used as initialState for the redux.

Example


import initialState from './store/default'
import reducer from './reducers'
import Layout from './components/layout'
const mikasa = require('mikasa')

mikasa({
        port: 3002,
        routes: routes,
        static: {
            path: '/public',
            local: './static',
            options: {
                gzip: true,
            }
        },
        layout: Layout,
        store: {
            initialState: initialState,
            reducer: reducer,
        },
        promises: [],
    })
}

Usage in browser

For the the browser usage import mikasa/browser. The configuration object is similar to the server one and it must contain the following attributes:

ParametersTypeDescription
reducerFunctionIt can be a simple reducer or a combined reducer.
routesArrayAn Array of Route Objects.
layoutReact ComponentThe React Component that will be used as layout.

Example in browser

import mikasa from 'mikasa/browser'
import reducer from '/reducers'
import routes from '/routes'
import layout from '/components/layout'

mikasa({
    reducer: reducer,
    routes: routes,
    layout: layout,
})

FAQs

Package last updated on 01 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.