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

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

D
Dan Zajdband 已提交
5 6 7 8 9 10
Download the example:

```bash
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz next.js-master/examples/shared-modules
cd next.js-master/examples/shared-modules
```
11

D
Dan Zajdband 已提交
12
or clone the repo:
13

D
Dan Zajdband 已提交
14 15 16 17 18 19 20 21
```bash
git clone git@github.com:zeit/next.js.git --depth=1
cd next.js/examples/shared-modules
```

Install the dependencies:

```bash
22
npm install
D
Dan Zajdband 已提交
23 24 25 26 27
```

Run the dev server:

```bash
28 29
npm run dev
```
D
Dan Zajdband 已提交
30 31 32 33 34 35 36

## 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