• Stars
    star
    113
  • Rank 300,383 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 5 years ago

Reviews

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

Repository Details

react made easy



react made easy

 

Build Status

 

minimal setup

npm install bae --save

Add these 2 lines in your package.json

"scripts": {
  "dev": "bae dev",
  "start": "bae"
}

Start the dev server with npm run dev. You just setup server rendering with hot module replacement and hot reload!

 

pages

Make pages like it's the 90s.  

  • pages are routes: pages/about renders /about of your website

  • pages are rendered on the server

  • pages are streamed to the browser for quick time-to-first-byte

  • built in code splitting, each page gets it's own page.js

  • code shared between pages is served as common.js for long term caching

  • pages/home.js renders the homepage /

  • why is this important?

 

import React from 'react'

export default class extends React.Component {
  constructor (props) {
    super(props)
    this.state = {message: 'hello'} // rendered on the server
  }
  componentDidMount () {
    this.setState({message: 'hello world'}) // updated on the browser
  }
  render () {
    return <div>{this.state.message}</div>
  }
}

 

asyncComponentWillMount

React has a lifecycle method that get's called on the server componentWillMount that can be used to set data for server rendering. But, it does not support asynchronous data fetching before rendering the component.

bae introduces a new lifecycle method to pages that runs only on the server.

import React from 'react'

export default class extends React.Component {
  constructor (props) {
    super(props)
    this.state = {username: 'siddharthkp'}
  }
  asyncComponentWillMount () {
    /*
      Return a promise.
      It will get resolved on the server and passed as props to the component.
    */
    return axios.get(`https://api.github.com/users/${this.state.username}`)
  }
  render () {
    return <div>{this.props.bio}</div>
  }
}

 

components

the usual, nothing special here.

 

styling

comes with styled-components which gets rendered on the server.

 

static assets

keep your images, fonts, etc. in a directory named static

 

production

npm start will compile, optimize and serve your app.

 

example

Check out the example applications to see how simple this is.

 

like it?

this repo

 

todo

  • init by default
  • easy api for lazy loading components
  • server worker support
  • make first build faster

 

license

 

MIT © siddharthkp

More Repositories

1

bundlesize

Keep your bundle size in check
JavaScript
4,437
star
2

cost-of-modules

Find out which of your dependencies are slowing you down 🐢
JavaScript
2,784
star
3

auto-install

Install dependencies as you code ⚡️
JavaScript
1,193
star
4

react-ui

Customisable components and primitives based on design tokens
JavaScript
417
star
5

notella

No fluff notes app
JavaScript
274
star
6

card-vibes

The card component with good vibes
JavaScript
262
star
7

babel-plugin-open-source

Alt + Click on rendered JSX to open it's source code in VSCode
JavaScript
184
star
8

github-build

Github builds for CI
JavaScript
131
star
9

react-amsterdam-videos

Timestamps from the react.asterdam livestream
127
star
10

women-tech-speakers-in-india

A list of women tech speakers in India
121
star
11

atom-import-cost

Check the size of the package you import
JavaScript
119
star
12

rest-your-eyes

Rest your eyes while your command runs 👀
JavaScript
106
star
13

css-constructor

💄 CSS constructor for React components
JavaScript
99
star
14

now-cd

continuous deployment with now
JavaScript
93
star
15

css-out-js

Author styles collocated in JS, pull them out into static CSS on build. No runtime dependency.
JavaScript
91
star
16

twitter-avatar

Get twitter avatar from a username
JavaScript
91
star
17

use-timeout

Declarative React hook for setTimeout
JavaScript
77
star
18

perfbench

Continuous integration for performance monitoring
JavaScript
74
star
19

tracer-motion

Visual debugger for framer-motion
JavaScript
69
star
20

reactron

☉ A shiny new React component library
JavaScript
67
star
21

historie

A searchable history cli
JavaScript
59
star
22

show-keys

Utility to show key presses in your application
JavaScript
57
star
23

react-vanilla-tilt

React wrapper around vanilla-tilt
JavaScript
53
star
24

twitter-timer

A tiny timer for twitter
JavaScript
51
star
25

saturday

Example app for React Day talk
JavaScript
48
star
26

bundlesize2

Keep your bundle size in check - version 2
JavaScript
48
star
27

prettycli

Pretty print messages on the terminal
JavaScript
47
star
28

learn-es6

Learn ES6 while converting your ES5 code!
JavaScript
46
star
29

ci-env

Environment variables exposed by CI tools
JavaScript
40
star
30

npm-cache-benchmark

Benchmark npm cache vs yarn
JavaScript
38
star
31

pay-with-a-star

Get paid in ⭐s for your open source work
JavaScript
34
star
32

react-docgen-external-proptypes-handler

evaluate variables from external files for react-docgen
JavaScript
34
star
33

toggle-icons

show/hide icons on your desktop
JavaScript
30
star
34

use-css

Silly React hook for CSS
JavaScript
25
star
35

storehook

silly state management library built with hooks
JavaScript
24
star
36

jsxo

Babel plugin that lets you create files with JSX only
JavaScript
22
star
37

useDebug

Custom hook to debug useEffect
JavaScript
21
star
38

react-rally-videos

Timestamps from the react.asterdam livestream
18
star
39

just-do-it-pls

a collaborative "art" project
HTML
18
star
40

use-event-listener

Declarative React hook for eventListener
JavaScript
16
star
41

tinyreact.email

Top 3 React articles of the week in your inbox
HTML
16
star
42

nps-i

Interactive mode for nps
JavaScript
16
star
43

tweetshot

Quicky grab a screenshot of a tweet
JavaScript
15
star
44

robocop

Robocop is a code review tool
JavaScript
15
star
45

markedup

WIP: Supercharged markdown rendering engine
JavaScript
14
star
46

babel-plugin-styled-components-require

Babel plugin that adds styled-components import declaration
JavaScript
13
star
47

travis.yml

Quickly create a .travis.yml for node projects
JavaScript
13
star
48

twitter-stats

Get followers for a user
JavaScript
11
star
49

atom-import-cost-beta

JavaScript
10
star
50

ynx

just like npx but b̶e̶t̶t̶e̶r̶ same
JavaScript
8
star
51

fakestagram

react web and native from the same codebase
JavaScript
8
star
52

ci-github-comment

Comment on pull requests from CI
JavaScript
8
star
53

vscode-settings

Copy of my editor setup
7
star
54

is-public

Check if a github repo is public
JavaScript
7
star
55

unique-string-pokemon

Get a unique hyphenated string like pikachu-used-thunder-shock
JavaScript
7
star
56

rehman

JavaScript
7
star
57

restylesheet

Best way to include stylesheet for developer-kids these days
JavaScript
7
star
58

use-key-debugger

React hook for visually debugging keyboard events
JavaScript
6
star
59

regithub

Playground to perform my React experiments
JavaScript
6
star
60

lazyfetch

Load stuff lazily on the browser
JavaScript
5
star
61

react-workshop

Companion repo
JavaScript
5
star
62

react-newsletter

Tools for react newsletter
JavaScript
5
star
63

react-ui-devtools-example

JavaScript
5
star
64

shelf-examples

Examples for using shelf
HTML
5
star
65

react-docgen-deprecation-handler

Add deprecation status in prop types
JavaScript
5
star
66

vanilla-extract-prototype

Built a couple components with vanilla extract
CSS
4
star
67

react-prototype

Designing with react, because why not?
JavaScript
4
star
68

prettyreadme

Automated my style of readme
JavaScript
4
star
69

gradients-api

Get colors for gradient name
JavaScript
4
star
70

advanced-react

JavaScript
3
star
71

ds-workshop

JavaScript
3
star
72

es6-on-production

ES6 on production? Not so fast
JavaScript
3
star
73

prettytext

I like gradients
JavaScript
3
star
74

ra-workshop

JavaScript
3
star
75

vhs

📼
JavaScript
3
star
76

supervisorduty

Checks supervisor status and raises a pager duty alert
JavaScript
3
star
77

beep

nodeschool workshop
JavaScript
3
star
78

dribbble

A design system for Dribbble
CSS
3
star
79

now-wrapper

A programmatic API around now CLI
JavaScript
3
star
80

dhai-kilo-ka-haath

dhai kilo ka file 💪
2
star
81

github-user

Get bio + popular repos for a user
JavaScript
2
star
82

sandbox

WIP: Sandbox 5
JavaScript
2
star
83

props-to-string

Human readable names for proptypes
2
star
84

dribbble-backup

JavaScript
2
star
85

heels

JavaScript
2
star
86

vite-example

Vue
2
star
87

codesee-example

JavaScript
2
star
88

calendar-tasks

Add BETTER tasks to google calendar
JavaScript
2
star
89

lighthouse-ci

Trying to run lighthouse on travis-ci
JavaScript
2
star
90

newstyle

CSS
1
star
91

github-comment

Comment on a pull request
JavaScript
1
star
92

siddharthkp

Personal readme <3
1
star
93

cdn-benchmarks

Benchmarking certain CDNs
JavaScript
1
star
94

rpm

experiment: download node_modules via a remote server with faster internet
JavaScript
1
star
95

whereami

JavaScript
1
star
96

dragonberry

Hackathon project with raspberry pi
JavaScript
1
star
97

advanced-component-patterns

Repo for advanced component patterns course
JavaScript
1
star
98

twitter-uid-to-username

Get username for uid
JavaScript
1
star
99

cronduty-cli

WIP: cron monitoring with minimal configuration 📟
JavaScript
1
star
100

p2pee

Hackathon project - find the nearest place to pee 🏃
JavaScript
1
star