2016-11-28 00:15:56 +00:00
# Example app using shared modules
2016-12-22 05:10:54 +00:00
## How to use
2016-11-28 00:15:56 +00:00
2016-12-22 05:10:54 +00:00
Download the example:
```bash
2016-12-22 09:07:54 +00:00
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/shared-modules
cd shared-modules
2016-12-22 05:10:54 +00:00
```
2016-11-28 00:15:56 +00:00
2016-12-22 05:10:54 +00:00
or clone the repo:
2016-11-28 00:15:56 +00:00
2016-12-22 05:10:54 +00:00
```bash
2016-12-22 09:14:12 +00:00
git clone https://github.com/zeit/next.js.git --depth=1
2016-12-22 05:10:54 +00:00
cd next.js/examples/shared-modules
```
Install the dependencies:
```bash
2016-11-28 00:15:56 +00:00
npm install
2016-12-22 05:10:54 +00:00
```
Run the dev server:
```bash
2016-11-28 00:15:56 +00:00
npm run dev
```
2016-12-22 05:10:54 +00:00
## 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