• Stars
    star
    477
  • Rank 92,112 (Top 2 %)
  • Language
    JavaScript
  • Created almost 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿš€ A quick way to prototype and build apps with React and Babel with zero-setup.

Quik

A quick way to prototype and build apps with React and Babel with zero-setup.

semantic-release npm version build status coverage status dependencies license

Setting up the tooling required to work on a modern day web app is hard, and makes quick prototyping much more difficult than it should be. Quik is a quick way to prototype a React application without any kind of setup. It can also generate a production-ready JavaScript bundle to use in your app. No setup required.

Quik runs a simple server that compiles JavaScript files with Babel on the fly, so you can include ES201x files in a script tag directly,

<script src="index.js"></script>

Tip: You can add ?transpile=false to the script src to skip the transpilation.

Quik also exposes a koa middleware which can be easily integrated with your server.

Features

  • One-time installation, no additional setup required
  • Hot Module Replacement
  • Generates bundles for use in production
  • Generates single standalone HTML file for sharing
  • React, Redux, React Router and Radium are already included
  • Quick prototyping with an optional starter template

Installation

You need at least Node 7.0 to run quik.

npm install --global quik

Usage

Open the Terminal in any directory and run the following,

quik

It'll start a simple server which will serve the files in the current directory. By default, it'll automatically watch the file index.js if present.

If no index.html file is present, it'll generate and serve an HTML file with it's script tag pointing to index.js file. Alternatively, you can specify the name of the script to include,

quik --run script.js

If you want to use a different port. For example, to run the server in the port 8008, run,

quik --port 8008

You can include any ES2015 file in a script tag in an HTML file and the script will be transpiled to ES5 on the fly. You can use JSX and Flow syntax as well as use ES2015 modules to import other scripts. It just works.

NOTE: You'll need to install any dependencies you use in the project manually.

Enabling Hot Module Replacement

Hot Module Replacement for React Components is automatically enabled if you have a script named index.js in the directory, or if you specified a script to run with the --run option, for example,

quik --run app.js

Alternatively, you can specify the filenames you want to watch for HMR,

quik --watch file1.js file2.js

When using the --run option, the index.html file is always generated on the fly and served. If you want to use your own index.html file, just use --watch.

You only need to specify the entry points, not all scripts. Most of the time it'll be just one script. Note that Hot Module Replacement won't work for any components in the entry points.

Generating JavaScript Bundle

The bundler provides an abstraction on top of webpack with sensible defaults for a React project. If you need additional customisation, use webpack directly for bundling.

To generate a bundle wth quik for use in your web application, run the following in a Terminal,

quik --bundle entry.js --output bundle.js --production

The --production option performs minification on the resulting bundle. You can omit it if you're not going to use the file in production.

You can provide multiple entry points as arguments. In that case, you can use [name] to get the name of the entry point while specifying an output file,

quik --bundle file1.js file2.js --output [name].bundle.js --common common.bundle.js

Sourcemap files are automatically generated when generating bundles.

Generating a sharable single HTML file

Sometimes you might want compile and inject bundles into an HTML file for easier sharing through dropbox, email etc. To do so, run the following in a Terminal,

quik --html --output output.html --production

You can also specify an HTML file, which quik will parse for any local scripts. Then it will build them and inject into the HTML file. It'll also inline stylesheets as is, without any pre-processing. Just open the generated HTML file in any browser to preview.

quik --html index.html --output output.html

Specify browser to open

You can specify which browser to open when server starts. Refer opn's documentation on browser names.

For example, to use firefox as the browser, you'd do,

quik --browser firefox

Sample project

To get started with a sample project, run the following in a Terminal,

quik --init AwesomeProject
cd AwesomeProject && quik

Refer the API documentation for more to know how to customize and extend the server.

How it works

The quik middleware is just an abstraction on top of webpack. It includes a base webpack config and generates appropriate config files when needed. For example, when the quik server receives a request for a JavaScript file, it generates a webpack config on the fly, the file is then transpiled with webpack, and the server responds with the generated bundle instead of the original script.

Motivation

Tooling is the hardest part in JavaScript development, and it's time we do something about it.

The following posts inspired me to work on quik,

One good thing about quik is that it is highly opinionated, which means we don't worry about becoming generic and can focus on making it better at what it does. It doesn't allow additional babel transforms, or loaders for webpack as of now.

Inline styles are recommended for styling. When combined with a library like radium, they provide much more flexibility than CSS.

The goal of quik is to improve the tooling around React and Babel projects. While it'll be easy enough to support additional customization, it defeats the whole purpose of being zero-setup. If you need additional configuration, it will be better to go with webpack directly. If you think something should be included by default, send a pull request or file a bug report.

Even though quik itself doesn't provide additional customization, it's just a koa middleware at the core. That means it's composable with other koa middlewares and you can add additional functionality easily.

Plans for improvements

Below are some ideas on how to improve quik. It would be awesome to receive pull requests for these.

  • Automatically parse HTML files to enable hot reloading without having to specify files with --watch
  • Cache bundles instead of re-building on every request
  • Better error handling
  • Atom plugin to make it easier to use without CLI

Similar tools

Of course, quik is not the only tool trying to solve this problem. There are few other tools which are also doing a great job at it.

  • react-heatpack - a very minimal prototyping server for React with Hot Module Replacement
  • nwb - similar, but has lot more options
  • rwb - pretty similar to quik, has Hot Module Replacement and can also build bundles for production
  • run-js - works on top of browserify, zero-setup, has live-reload functionality

More Repositories

1

react-native-tab-view

A cross-platform Tab View component for React Native
TypeScript
5,136
star
2

react-simple-code-editor

Simple no-frills code editor with syntax highlighting
TypeScript
1,103
star
3

react-navigation-addons

Add-ons for React Navigation
JavaScript
282
star
4

web-worker-proxy

A better way of working with web workers
JavaScript
225
star
5

PocketGear

A clean and simple Pokรฉdex app for Pokรฉmon GO
TypeScript
200
star
6

monaco-editor-boilerplate

A simple boilerplate for Monaco editor with React.
JavaScript
187
star
7

gtk-theme-config

A tool to configure GTK theme colors.
Vala
89
star
8

babel-test

An opinionated library to make testing babel plugins easier.
JavaScript
80
star
9

react-boilerplate

An simple webpack boilerplate for React projects.
JavaScript
61
star
10

react-navigation-native-modal

React Navigation integration for React Native's Modal component
TypeScript
60
star
11

babel-plugin-css-prop

Babel plugin to transpile `css` prop to a styled component. (Experimental)
JavaScript
55
star
12

babel-plugin-optional-require

Babel plugin to optionaly require modules
JavaScript
52
star
13

react-native-in-app-purchase

IAP for React Native
Java
49
star
14

eslint-config-satya164

An ESLint config with automatic overrides for common environments such as TypeScript, Jest etc.
JavaScript
49
star
15

jest-file-snapshot

Jest matcher to write snapshots to a separate file instead of the default snapshot file used by Jest
JavaScript
41
star
16

babel-plugin-object-styles-to-template

Babel plugin to transpile object styles to template literal
JavaScript
35
star
17

typescript-template

Template repository for TypeScript projects with Babel
JavaScript
32
star
18

use-latest-callback

TypeScript
28
star
19

gjs-helpers

GNOME JavaScript helpers for async tasks
JavaScript
26
star
20

react-native-image-chooser

A React Native module to show system Image chooser. Currently only supports Android.
Java
26
star
21

Evolve

Evolve is a simple and minimal light theme designed to be easy on the eyes.
CSS
24
star
22

github-transfer-issues

Bulk transfer GitHub issues with puppeteer
JavaScript
23
star
23

emoji-invaders

Simple Emoji Invaders game
JavaScript
14
star
24

animated-to-reanimated

Helper to convert an Animated value to Reanimated and vice-versa
Java
12
star
25

grrr

A small tool to generate gresource files
JavaScript
11
star
26

minimal.widget

A minimal widget for รœbersicht which displays a panel on top right and apps list on top left
JavaScript
11
star
27

pigment

Color information, conversion and manipulation library
JavaScript
9
star
28

react-canvas-renderer

Custom React renderer which renders to <canvas />
JavaScript
8
star
29

random-color

Show a random color on tap.
Objective-C
6
star
30

publish-monorepo-packages

Tool to make easier publish packages in monorepo to the registry.
TypeScript
6
star
31

warn-once

Show a warning once
JavaScript
5
star
32

react-native-share

Java
5
star
33

language-x

An all new programming language
JavaScript
4
star
34

snack-modules

JavaScript
4
star
35

meme-generator

Meme Generator app built with Expo
JavaScript
4
star
36

json2scss

Convert JSON config files to SCSS!
JavaScript
4
star
37

croma

JavaScript
4
star
38

reanimated-2-drawer

TypeScript
3
star
39

huematic

Generate color schemes based on algorithms
JavaScript
3
star
40

react-native-jsitestlibrary

Java
3
star
41

actions-playground

Playing with GitHub actions
3
star
42

git-hooks-scripts

Run custom scripts as Git hooks
JavaScript
3
star
43

turbo-module-example

Example for backward compatible Turbo module
Java
2
star
44

drop-shadows

Generate drop shadows
OCaml
2
star
45

magnetic-field-meter

Detect Magnetic field using device's Magnetometer
JavaScript
2
star
46

webrtc-messaging

TypeScript
2
star
47

simple-website-boilerplate

A simple website boilerplate with BrowserSync and Sass
HTML
2
star
48

remark-syntax-highlight

(WIP) Syntax highlight code blocks with a custom highlight function in remark
JavaScript
2
star
49

turtle-v2-example

Java
2
star
50

timezones

JavaScript
1
star
51

dotfiles

JavaScript
1
star
52

animated-helpers

Helpers for React Native's Animated API
TypeScript
1
star
53

node-app-tasks

The action allows to run any npm/yarn command or a task defined in package.json
Shell
1
star
54

keycode

Find keyCode of a key
HTML
1
star