README.md 745 字节
Newer Older
1 2
# Example app using shared modules

D
Dan Zajdband 已提交
3
## How to use
4

S
Sébastien Dubois 已提交
5
Download the example [or clone the repo](https://github.com/zeit/next.js):
D
Dan Zajdband 已提交
6 7

```bash
N
nkzawa 已提交
8 9
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/shared-modules
cd shared-modules
D
Dan Zajdband 已提交
10
```
11

D
Dan Zajdband 已提交
12
Install it and run:
D
Dan Zajdband 已提交
13 14

```bash
15
npm install
D
Dan Zajdband 已提交
16
npm run dev
D
Dan Zajdband 已提交
17 18
```

D
Dan Zajdband 已提交
19
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
D
Dan Zajdband 已提交
20 21

```bash
D
Dan Zajdband 已提交
22
now
23
```
D
Dan Zajdband 已提交
24 25 26 27 28 29 30

## The idea behind the example

This example features:

* An app with two pages which has a common Counter component
* That Counter component maintain the counter inside its module. This is used primarily to illustrate that modules get initialized once and their state variables persist in runtime