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

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

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

```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
or clone the repo:
13

D
Dan Zajdband 已提交
14
```bash
N
nkzawa 已提交
15
git clone https://github.com/zeit/next.js.git --depth=1
D
Dan Zajdband 已提交
16 17 18 19 20 21
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