├── .npmrc ├── test ├── isolated │ └── _resolvedata │ │ ├── one.js │ │ ├── aa │ │ └── index.js │ │ ├── cc │ │ ├── index.js │ │ └── index.json │ │ ├── one.json │ │ ├── two.json │ │ └── bb │ │ └── index.json └── integration │ ├── basic │ ├── lib │ │ ├── data.json │ │ └── cdm.js │ ├── pages │ │ ├── no-default-export.js │ │ ├── index.js │ │ ├── with-cdm.js │ │ ├── nested-cdm │ │ │ └── index.js │ │ ├── error.js │ │ ├── stateless.js │ │ ├── json.js │ │ ├── dynamic │ │ │ ├── ssr.js │ │ │ ├── no-ssr.js │ │ │ ├── index.js │ │ │ ├── no-ssr-custom-loading.js │ │ │ └── no-chunk.js │ │ ├── hmr │ │ │ ├── about.js │ │ │ └── contact.js │ │ ├── styled-jsx.js │ │ ├── link.js │ │ ├── empty-get-initial-props.js │ │ ├── finish-response.js │ │ ├── head.js │ │ ├── nav │ │ │ ├── about.js │ │ │ ├── as-path.js │ │ │ ├── redirect.js │ │ │ ├── as-path-using-router.js │ │ │ ├── self-reload.js │ │ │ ├── querystring.js │ │ │ └── hash-changes.js │ │ ├── async-props.js │ │ └── stateful.js │ ├── components │ │ ├── hello1.js │ │ ├── hello2.js │ │ ├── hello-context.js │ │ └── welcome.js │ ├── next.config.js │ └── test │ │ └── misc.js │ ├── dist-dir │ ├── pages │ │ └── index.js │ └── next.config.js │ ├── production │ ├── components │ │ ├── hello1.js │ │ ├── hello2.js │ │ ├── hello-context.js │ │ └── welcome.js │ └── pages │ │ ├── about.js │ │ ├── dynamic │ │ ├── ssr.js │ │ ├── no-ssr.js │ │ ├── index.js │ │ ├── no-ssr-custom-loading.js │ │ └── no-chunk.js │ │ └── index.js │ ├── ondemand │ ├── pages │ │ ├── about.js │ │ └── index.js │ └── next.config.js │ └── static │ ├── components │ └── hello.js │ ├── pages │ ├── about.js │ ├── get-initial-props-with-no-query.js │ ├── button-link.js │ ├── level1 │ │ ├── about.js │ │ └── index.js │ ├── dynamic-imports.js │ ├── counter.js │ └── dynamic.js │ ├── next.config.js │ └── test │ └── index.test.js ├── examples ├── .gitignore ├── .babelrc ├── with-dotenv │ ├── .env │ ├── .env.production │ ├── pages │ │ └── index.js │ ├── .babelrc │ └── package.json ├── with-typescript │ ├── .gitignore │ ├── components │ │ └── MyComponent.tsx │ ├── tsconfig.json │ ├── pages │ │ └── index.tsx │ ├── package.json │ └── README.md ├── with-external-scoped-css │ ├── .gitignore │ ├── global.sass │ ├── pages │ │ ├── index.sass │ │ ├── index.js │ │ └── _document.js │ ├── pre-processor.js │ ├── .babelrc │ ├── package.json │ └── README.md ├── with-react-intl │ ├── .gitignore │ ├── lang │ │ ├── en.json │ │ └── fr.json │ ├── .babelrc │ ├── package.json │ ├── pages │ │ ├── about.js │ │ └── index.js │ ├── components │ │ ├── Layout.js │ │ └── Nav.js │ └── scripts │ │ └── default-lang.js ├── custom-server-koa │ ├── pages │ │ ├── a.js │ │ ├── b.js │ │ └── index.js │ └── package.json ├── root-static-files │ ├── static │ │ ├── robots.txt │ │ ├── favicon.ico │ │ └── sitemap.xml │ ├── pages │ │ └── index.js │ ├── package.json │ ├── README.md │ └── server.js ├── custom-server-express │ ├── pages │ │ ├── a.js │ │ ├── b.js │ │ └── index.js │ ├── package.json │ └── server.js ├── with-i18next │ ├── static │ │ └── locales │ │ │ ├── id │ │ │ └── common.json │ │ │ └── pt │ │ │ └── common.json │ ├── components │ │ └── Title.js │ ├── tools │ │ ├── startI18n.js │ │ └── translationHelpers.js │ ├── package.json │ ├── README.md │ └── pages │ │ └── index.js ├── hello-world │ ├── pages │ │ ├── about.js │ │ └── index.js │ ├── package.json │ └── README.md ├── with-shallow-routing │ ├── pages │ │ └── about.js │ ├── package.json │ └── README.md ├── custom-server │ ├── pages │ │ ├── a.js │ │ ├── b.js │ │ └── index.js │ ├── package.json │ └── server.js ├── with-flow │ ├── .flowconfig │ ├── with-flow.gif │ ├── .babelrc │ ├── pages │ │ ├── index.js │ │ ├── about.js │ │ └── contact.js │ ├── package.json │ ├── components │ │ └── layout.js │ └── README.md ├── with-react-helmet │ ├── pages │ │ └── index.js │ └── package.json ├── with-scoped-stylesheets-and-postcss │ ├── pages │ │ ├── global.css │ │ ├── styles.css │ │ └── index.js │ ├── postcss.config.js │ └── package.json ├── with-styled-jsx-postcss │ ├── .babelrc │ ├── postcss.config.js │ ├── babel-preset.js │ ├── package.json │ └── pages │ │ └── index.js ├── custom-server-hapi │ ├── pages │ │ ├── a.js │ │ ├── b.js │ │ └── index.js │ ├── package.json │ └── next-wrapper.js ├── with-firebase │ ├── credentials │ │ ├── client.js │ │ └── server.js │ └── package.json ├── with-next-routes │ ├── pages │ │ ├── about.js │ │ ├── index.js │ │ └── blog.js │ ├── routes.js │ ├── package.json │ └── server.js ├── with-webpack-bundle-analyzer │ ├── pages │ │ ├── about.js │ │ ├── contact.js │ │ └── index.js │ ├── next.config.js │ ├── package.json │ └── README.md ├── svg-components │ ├── .babelrc │ ├── package.json │ ├── pages │ │ └── index.js │ └── README.md ├── with-amp │ ├── static │ │ ├── cat.jpg │ │ └── dog.jpg │ ├── components │ │ └── Byline.js │ ├── package.json │ └── README.md ├── with-custom-babel-config │ ├── .babelrc │ └── package.json ├── with-react-md │ ├── static │ │ └── react-md.light_blue-yellow.min.css │ ├── next.config.js │ └── package.json ├── using-inferno │ ├── pages │ │ ├── about.js │ │ └── index.js │ ├── next.config.js │ ├── package.json │ └── server.js ├── using-preact │ ├── pages │ │ ├── about.js │ │ └── index.js │ ├── package.json │ ├── next.config.js │ └── server.js ├── with-dynamic-import │ ├── components │ │ ├── hello1.js │ │ ├── hello2.js │ │ ├── hello3.js │ │ ├── hello4.js │ │ ├── hello5.js │ │ ├── hello6.js │ │ ├── hello7.js │ │ ├── Header.js │ │ └── Counter.js │ ├── pages │ │ └── about.js │ ├── package.json │ └── README.md ├── with-global-stylesheet │ ├── example.gif │ ├── styles │ │ ├── index.css │ │ └── index.scss │ ├── postcss.config.js │ ├── pages │ │ └── index.js │ ├── .babelrc │ ├── package.json │ └── next.config.js ├── with-mobx │ ├── .babelrc │ ├── package.json │ ├── server.js │ ├── components │ │ ├── Clock.js │ │ └── Page.js │ ├── pages │ │ ├── other.js │ │ └── index.js │ └── store.js ├── with-refnux │ ├── store │ │ ├── setTitle.js │ │ ├── getInitialState.js │ │ ├── counterIncrement.js │ │ └── getStore.js │ ├── package.json │ ├── helpers │ │ └── getStore.js │ └── pages │ │ ├── page2.js │ │ └── page1.js ├── with-universal-configuration │ ├── pages │ │ └── index.js │ ├── .babelrc │ ├── env-config.js │ └── package.json ├── with-react-ga │ ├── pages │ │ ├── about.js │ │ └── index.js │ ├── package.json │ ├── components │ │ └── Layout.js │ └── utils │ │ └── analytics.js ├── layout-component │ ├── pages │ │ ├── index.js │ │ ├── about.js │ │ └── contact.js │ ├── package.json │ └── components │ │ └── layout.js ├── using-router │ ├── pages │ │ ├── index.js │ │ ├── about.js │ │ └── error.js │ ├── package.json │ ├── components │ │ └── Header.js │ └── README.md ├── with-ant-design │ ├── .babelrc │ ├── package.json │ └── README.md ├── with-prefetching │ ├── pages │ │ ├── about.js │ │ ├── index.js │ │ ├── contact.js │ │ └── features.js │ ├── package.json │ └── components │ │ └── Header.js ├── with-styled-components │ ├── .babelrc │ ├── pages │ │ ├── index.js │ │ └── _document.js │ └── package.json ├── with-jest │ ├── pages │ │ └── index.js │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.js.snap │ │ └── index.test.js │ ├── .babelrc │ ├── package.json │ └── README.md ├── with-loading │ ├── pages │ │ ├── index.js │ │ ├── about.js │ │ └── forever.js │ ├── package.json │ └── components │ │ └── Header.js ├── with-fela │ ├── layout.js │ ├── fela-renderer.js │ ├── package.json │ └── pages │ │ └── index.js ├── with-styletron │ ├── next.config.js │ ├── layout.js │ ├── pages │ │ ├── index.js │ │ └── _document.js │ ├── package.json │ └── styletron.js ├── nested-components │ ├── components │ │ ├── paragraph.js │ │ └── post.js │ └── package.json ├── shared-modules │ ├── pages │ │ ├── index.js │ │ └── about.js │ ├── package.json │ └── components │ │ ├── Header.js │ │ └── Counter.js ├── with-antd-mobile │ ├── .babelrc │ ├── pages │ │ ├── index.js │ │ └── _document.js │ ├── package.json │ ├── components │ │ └── Layout.js │ ├── static │ │ ├── reload.svg │ │ └── hd.min.js │ └── README.md ├── with-apollo-and-redux │ ├── lib │ │ └── reducers.js │ ├── pages │ │ └── index.js │ ├── package.json │ └── components │ │ └── Header.js ├── basic-css │ ├── package.json │ └── pages │ │ └── index.js ├── with-material-ui │ ├── next.config.js │ ├── package.json │ └── README.md ├── with-pretty-url-routing │ ├── pages │ │ └── index.js │ ├── package.json │ ├── routes.js │ ├── server.js │ └── README.md ├── head-elements │ ├── package.json │ └── pages │ │ └── index.js ├── progressive-render │ ├── components │ │ └── Loading.js │ ├── package.json │ └── pages │ │ └── index.js ├── with-material-ui-next │ ├── package.json │ └── README.md ├── with-glamor │ ├── package.json │ └── pages │ │ ├── index.js │ │ └── _document.js ├── with-higher-order-component │ ├── package.json │ ├── pages │ │ └── index.js │ ├── components │ │ └── withApp.js │ └── README.md ├── data-fetch │ ├── package.json │ └── pages │ │ ├── index.js │ │ └── preact.js ├── with-sw-precache │ ├── package.json │ ├── next.config.js │ ├── pages │ │ └── index.js │ └── server.js ├── with-cxs │ ├── package.json │ └── pages │ │ ├── _document.js │ │ └── index.js ├── with-react-uwp │ ├── package.json │ ├── components │ │ └── ThemeWrapper.js │ └── README.md ├── with-semantic-ui │ ├── package.json │ └── README.md ├── ssr-caching │ ├── pages │ │ ├── index.js │ │ └── blog.js │ └── package.json ├── with-aphrodite │ ├── package.json │ └── pages │ │ └── index.js ├── parameterized-routing │ ├── package.json │ ├── pages │ │ ├── index.js │ │ └── blog.js │ └── server.js ├── with-glamorous │ ├── package.json │ └── pages │ │ └── _document.js ├── with-url-object-routing │ ├── package.json │ ├── pages │ │ ├── index.js │ │ └── about.js │ └── server.js ├── with-apollo │ ├── pages │ │ └── index.js │ ├── package.json │ └── components │ │ └── Header.js ├── with-react-toolbox │ └── pages │ │ └── index.js ├── with-socket.io │ ├── package.json │ └── server.js └── with-redux │ ├── components │ ├── Page.js │ ├── Clock.js │ └── AddCount.js │ ├── package.json │ └── pages │ └── other.js ├── css.js ├── error.js ├── head.js ├── link.js ├── pages ├── _error.js └── _document.js ├── dynamic.js ├── prefetch.js ├── router.js ├── document.js ├── babel.js ├── bench ├── pages │ ├── stateless.js │ └── stateless-big.js ├── package.json └── readme.md ├── server ├── next.js ├── require.js ├── build │ ├── clean.js │ ├── replace.js │ ├── babel │ │ └── find-config.js │ ├── plugins │ │ ├── unlink-file-plugin.js │ │ ├── watch-pages-plugin.js │ │ └── combine-assets-plugin.js │ └── loaders │ │ └── emit-file-loader.js ├── utils.js └── router.js ├── client ├── next.js └── on-demand-entries-client.js ├── lib ├── css.js ├── shallow-equals.js └── prefetch.js ├── .gitignore ├── .babelrc ├── .travis.yml ├── appveyor.yml ├── wallaby.js └── contributing.md /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact = true 2 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/one.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | **/yarn.lock 2 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/aa/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/cc/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/one.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/two.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/bb/index.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/isolated/_resolvedata/cc/index.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "babelrc": false 3 | } -------------------------------------------------------------------------------- /examples/with-dotenv/.env: -------------------------------------------------------------------------------- 1 | TEST=it works! 2 | -------------------------------------------------------------------------------- /examples/with-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | **/*.js 2 | -------------------------------------------------------------------------------- /css.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/css') 2 | -------------------------------------------------------------------------------- /examples/with-external-scoped-css/.gitignore: -------------------------------------------------------------------------------- 1 | static -------------------------------------------------------------------------------- /error.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/error') 2 | -------------------------------------------------------------------------------- /examples/with-dotenv/.env.production: -------------------------------------------------------------------------------- 1 | TEST=it works! 2 | -------------------------------------------------------------------------------- /examples/with-react-intl/.gitignore: -------------------------------------------------------------------------------- 1 | lang/.messages/ 2 | -------------------------------------------------------------------------------- /head.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/head') 2 | -------------------------------------------------------------------------------- /link.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/link') 2 | -------------------------------------------------------------------------------- /pages/_error.js: -------------------------------------------------------------------------------- 1 | module.exports = require('next/error') 2 | -------------------------------------------------------------------------------- /dynamic.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/dynamic') 2 | -------------------------------------------------------------------------------- /prefetch.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/prefetch') 2 | -------------------------------------------------------------------------------- /router.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/lib/router') 2 | -------------------------------------------------------------------------------- /document.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/server/document') 2 | -------------------------------------------------------------------------------- /pages/_document.js: -------------------------------------------------------------------------------- 1 | module.exports = require('next/document') 2 | -------------------------------------------------------------------------------- /test/integration/basic/lib/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Zeit" 3 | } -------------------------------------------------------------------------------- /babel.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/server/build/babel/preset') 2 | -------------------------------------------------------------------------------- /bench/pages/stateless.js: -------------------------------------------------------------------------------- 1 | export default () =>

My component!

2 | -------------------------------------------------------------------------------- /test/integration/basic/pages/no-default-export.js: -------------------------------------------------------------------------------- 1 | export default {} 2 | -------------------------------------------------------------------------------- /examples/custom-server-koa/pages/a.js: -------------------------------------------------------------------------------- 1 | export default () =>
a
2 | -------------------------------------------------------------------------------- /examples/custom-server-koa/pages/b.js: -------------------------------------------------------------------------------- 1 | export default () =>
b
2 | -------------------------------------------------------------------------------- /examples/root-static-files/static/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: / 3 | -------------------------------------------------------------------------------- /examples/custom-server-express/pages/a.js: -------------------------------------------------------------------------------- 1 | export default () =>
a
2 | -------------------------------------------------------------------------------- /examples/custom-server-express/pages/b.js: -------------------------------------------------------------------------------- 1 | export default () =>
b
2 | -------------------------------------------------------------------------------- /examples/with-i18next/static/locales/id/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "hello": "halo" 3 | } -------------------------------------------------------------------------------- /test/integration/basic/pages/index.js: -------------------------------------------------------------------------------- 1 | import CDM from '../lib/cdm' 2 | export default CDM 3 | -------------------------------------------------------------------------------- /examples/hello-world/pages/about.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
About us
3 | ) 4 | -------------------------------------------------------------------------------- /test/integration/basic/pages/with-cdm.js: -------------------------------------------------------------------------------- 1 | import CDM from '../lib/cdm' 2 | export default CDM 3 | -------------------------------------------------------------------------------- /examples/with-shallow-routing/pages/about.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
About us
3 | ) 4 | -------------------------------------------------------------------------------- /test/integration/basic/components/hello1.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 1

3 | ) 4 | -------------------------------------------------------------------------------- /test/integration/basic/components/hello2.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 2

3 | ) 4 | -------------------------------------------------------------------------------- /test/integration/dist-dir/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
Hello World
3 | ) 4 | -------------------------------------------------------------------------------- /examples/custom-server/pages/a.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () =>
a
4 | -------------------------------------------------------------------------------- /examples/custom-server/pages/b.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () =>
b
4 | -------------------------------------------------------------------------------- /examples/with-dotenv/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
{ process.env.TEST }
3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-flow/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | types/ 7 | 8 | [options] 9 | -------------------------------------------------------------------------------- /examples/with-react-helmet/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => (
2 | Hello World! 3 |
) 4 | -------------------------------------------------------------------------------- /examples/with-scoped-stylesheets-and-postcss/pages/global.css: -------------------------------------------------------------------------------- 1 | .font-color { 2 | color: blue; 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-styled-jsx-postcss/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "./babel-preset" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/basic/pages/nested-cdm/index.js: -------------------------------------------------------------------------------- 1 | import CDM from '../../lib/cdm' 2 | export default CDM 3 | -------------------------------------------------------------------------------- /test/integration/production/components/hello1.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 1

3 | ) 4 | -------------------------------------------------------------------------------- /test/integration/production/components/hello2.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 2

3 | ) 4 | -------------------------------------------------------------------------------- /examples/custom-server-hapi/pages/a.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () =>
a
4 | -------------------------------------------------------------------------------- /examples/custom-server-hapi/pages/b.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () =>
b
4 | -------------------------------------------------------------------------------- /examples/with-firebase/credentials/client.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // TODO firebase client config 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-firebase/credentials/server.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // TODO firebase server config 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-i18next/static/locales/pt/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "hello": "e ae tche", 3 | "morning": "manha" 4 | } -------------------------------------------------------------------------------- /examples/with-next-routes/pages/about.js: -------------------------------------------------------------------------------- 1 | export default props =>

About foo {props.url.query.foo}

2 | -------------------------------------------------------------------------------- /examples/with-webpack-bundle-analyzer/pages/about.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
About us
3 | ) 4 | -------------------------------------------------------------------------------- /server/next.js: -------------------------------------------------------------------------------- 1 | import Server from './' 2 | 3 | module.exports = (opts) => { 4 | return new Server(opts) 5 | } 6 | -------------------------------------------------------------------------------- /examples/svg-components/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "next/babel" ], 3 | "plugins": [ "inline-react-svg" ] 4 | } 5 | -------------------------------------------------------------------------------- /examples/with-amp/static/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/functions/next.js/v3-beta/examples/with-amp/static/cat.jpg -------------------------------------------------------------------------------- /examples/with-amp/static/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/functions/next.js/v3-beta/examples/with-amp/static/dog.jpg -------------------------------------------------------------------------------- /examples/with-custom-babel-config/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel", 4 | "stage-0" 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /examples/with-flow/with-flow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/functions/next.js/v3-beta/examples/with-flow/with-flow.gif -------------------------------------------------------------------------------- /test/integration/basic/pages/error.js: -------------------------------------------------------------------------------- 1 | export default () => { 2 | throw new Error('This is an expected error') 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-react-md/static/react-md.light_blue-yellow.min.css: -------------------------------------------------------------------------------- 1 | ../node_modules/react-md/dist/react-md.light_blue-yellow.min.css -------------------------------------------------------------------------------- /test/integration/basic/pages/stateless.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () =>

My component!

4 | -------------------------------------------------------------------------------- /test/integration/ondemand/pages/about.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 |

About Page

4 |
5 | ) 6 | -------------------------------------------------------------------------------- /test/integration/production/pages/about.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
About Page
3 | ) 4 | -------------------------------------------------------------------------------- /examples/using-inferno/pages/about.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () => ( 4 |
About us
5 | ) 6 | -------------------------------------------------------------------------------- /examples/using-preact/pages/about.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default () => ( 4 |
About us
5 | ) 6 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello1.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 1 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello2.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 2 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello3.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 3 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello4.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 4 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello5.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 5 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello6.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 6 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/hello7.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello World 7 (imported dynamiclly)

3 | ) 4 | -------------------------------------------------------------------------------- /test/integration/static/components/hello.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

3 | Welcome to dynamic imports. 4 |

5 | ) 6 | -------------------------------------------------------------------------------- /test/integration/basic/pages/json.js: -------------------------------------------------------------------------------- 1 | import data from '../lib/data' 2 | 3 | export default () => ( 4 |
{data.name}
5 | ) 6 | -------------------------------------------------------------------------------- /test/integration/ondemand/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | onDemandEntries: { 3 | maxInactiveAge: 1000 * 5 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /client/next.js: -------------------------------------------------------------------------------- 1 | import next from './' 2 | 3 | next() 4 | .catch((err) => { 5 | console.error(`${err.message}\n${err.stack}`) 6 | }) 7 | -------------------------------------------------------------------------------- /examples/with-external-scoped-css/global.sass: -------------------------------------------------------------------------------- 1 | @mixin opacity($opacity) 2 | opacity: $opacity 3 | filter: alpha(opacity=($opacity * 100)) -------------------------------------------------------------------------------- /examples/with-global-stylesheet/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/functions/next.js/v3-beta/examples/with-global-stylesheet/example.gif -------------------------------------------------------------------------------- /examples/with-global-stylesheet/styles/index.css: -------------------------------------------------------------------------------- 1 | @import 'normalize.css'; 2 | 3 | p { 4 | font-size: xx-large; 5 | color: black; 6 | } 7 | -------------------------------------------------------------------------------- /examples/with-styled-jsx-postcss/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = () => ({ 2 | plugins: { 3 | 'postcss-cssnext': {} 4 | } 5 | }) 6 | -------------------------------------------------------------------------------- /examples/root-static-files/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/functions/next.js/v3-beta/examples/root-static-files/static/favicon.ico -------------------------------------------------------------------------------- /examples/with-amp/components/Byline.js: -------------------------------------------------------------------------------- 1 | export default ({ author }) => ( 2 |
3 | By {author} 4 |
5 | ) 6 | -------------------------------------------------------------------------------- /examples/with-mobx/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "plugins": [ 6 | "transform-decorators-legacy" 7 | ] 8 | } -------------------------------------------------------------------------------- /examples/with-webpack-bundle-analyzer/pages/contact.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 | This is the contact page. 4 |
5 | ) 6 | -------------------------------------------------------------------------------- /examples/with-scoped-stylesheets-and-postcss/pages/styles.css: -------------------------------------------------------------------------------- 1 | .paragraph { 2 | composes: font-color from './global.css'; 3 | font-size: 20px; 4 | } 5 | -------------------------------------------------------------------------------- /examples/with-flow/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "plugins": [ 6 | "transform-flow-strip-types" 7 | ] 8 | } -------------------------------------------------------------------------------- /examples/with-refnux/store/setTitle.js: -------------------------------------------------------------------------------- 1 | 2 | const setTitle = (newTitle) => ({title}) => { 3 | return { title: newTitle } 4 | } 5 | 6 | export default setTitle 7 | -------------------------------------------------------------------------------- /examples/hello-world/pages/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | export default () => ( 3 |
Hello World. About
4 | ) 5 | -------------------------------------------------------------------------------- /examples/with-universal-configuration/pages/index.js: -------------------------------------------------------------------------------- 1 | /* global BACKEND_URL */ 2 | 3 | export default () => ( 4 |
Loading data from { BACKEND_URL }
5 | ) 6 | -------------------------------------------------------------------------------- /examples/with-typescript/components/MyComponent.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | export default () => 4 |
5 |

This is my component

6 |
7 | -------------------------------------------------------------------------------- /lib/css.js: -------------------------------------------------------------------------------- 1 | throw new Error(`'next/css' has been removed in Next.js 2.0. Please refer to the migration guide: https://github.com/zeit/next.js/wiki/Migrating-from-next-css`) 2 | -------------------------------------------------------------------------------- /test/integration/basic/pages/dynamic/ssr.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | 3 | const Hello = dynamic(import('../../components/hello1')) 4 | 5 | export default Hello 6 | -------------------------------------------------------------------------------- /examples/with-external-scoped-css/pages/index.sass: -------------------------------------------------------------------------------- 1 | @import "../global" 2 | 3 | .example 4 | @include opacity(0.5) 5 | font-size: 36px 6 | width: 300px 7 | display: flex 8 | -------------------------------------------------------------------------------- /examples/with-react-ga/pages/about.js: -------------------------------------------------------------------------------- 1 | import Layout from '../components/Layout' 2 | 3 | export default () => ( 4 | 5 |
About us
6 |
7 | ) 8 | -------------------------------------------------------------------------------- /examples/with-universal-configuration/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "plugins": [ 6 | ["transform-define", "./env-config.js"] 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /server/require.js: -------------------------------------------------------------------------------- 1 | import resolve from './resolve' 2 | 3 | export default async function requireModule (path) { 4 | const f = await resolve(path) 5 | return require(f) 6 | } 7 | -------------------------------------------------------------------------------- /test/integration/production/pages/dynamic/ssr.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | 3 | const Hello = dynamic(import('../../components/hello1')) 4 | 5 | export default Hello 6 | -------------------------------------------------------------------------------- /examples/layout-component/pages/index.js: -------------------------------------------------------------------------------- 1 | import Layout from '../components/layout' 2 | 3 | export default () => ( 4 | 5 |
Hello World.
6 |
7 | ) 8 | -------------------------------------------------------------------------------- /examples/with-global-stylesheet/styles/index.scss: -------------------------------------------------------------------------------- 1 | @import 'normalize.css'; 2 | 3 | $primary-color: black; 4 | 5 | p { 6 | font-size: xx-large; 7 | color: $primary-color; 8 | } 9 | -------------------------------------------------------------------------------- /examples/with-refnux/store/getInitialState.js: -------------------------------------------------------------------------------- 1 | const getInitialState = () => { 2 | return { 3 | title: '', 4 | counter: 0 5 | } 6 | } 7 | 8 | export default getInitialState 9 | -------------------------------------------------------------------------------- /test/integration/basic/pages/hmr/about.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 |

4 | This is the about page. 5 |

6 |
7 | ) 8 | -------------------------------------------------------------------------------- /examples/with-i18next/components/Title.js: -------------------------------------------------------------------------------- 1 | import { translate } from 'react-i18next' 2 | export default translate(['common'])((props) => (

{props.t('hello')}, {props.t('morning')}

)) 3 | -------------------------------------------------------------------------------- /examples/with-refnux/store/counterIncrement.js: -------------------------------------------------------------------------------- 1 | 2 | const counterIncrement = ({counter}, dispatch) => { 3 | return { counter: counter + 1 } 4 | } 5 | 6 | export default counterIncrement 7 | -------------------------------------------------------------------------------- /test/integration/basic/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | onDemandEntries: { 3 | // Make sure entries are not getting disposed. 4 | maxInactiveAge: 1000 * 60 * 60 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/integration/basic/pages/hmr/contact.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 |

4 | This is the contact page. 5 |

6 |
7 | ) 8 | -------------------------------------------------------------------------------- /test/integration/basic/pages/styled-jsx.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 |

This is blue

4 | 5 |
6 | ) 7 | -------------------------------------------------------------------------------- /examples/using-router/pages/index.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | 3 | export default () => ( 4 |
5 |
6 |

HOME PAGE is here!

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /examples/with-ant-design/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "plugins": [ 6 | ["import", { 7 | "libraryName": "antd" 8 | }] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/basic/pages/dynamic/no-ssr.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | 3 | const Hello = dynamic(import('../../components/hello1'), { ssr: false }) 4 | 5 | export default Hello 6 | -------------------------------------------------------------------------------- /examples/layout-component/pages/about.js: -------------------------------------------------------------------------------- 1 | import Layout from '../components/layout' 2 | 3 | export default () => ( 4 | 5 |
About us
6 |
7 | ) 8 | -------------------------------------------------------------------------------- /examples/layout-component/pages/contact.js: -------------------------------------------------------------------------------- 1 | import Layout from '../components/layout' 2 | 3 | export default () => ( 4 | 5 |
Contact
6 |
7 | ) 8 | -------------------------------------------------------------------------------- /examples/using-router/pages/about.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | 3 | export default () => ( 4 |
5 |
6 |

This is the about page.

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /test/integration/basic/pages/dynamic/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 | No Chunk 6 |
7 | ) 8 | -------------------------------------------------------------------------------- /test/integration/basic/pages/link.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | export default () => ( 4 |
Hello World. About
5 | ) 6 | -------------------------------------------------------------------------------- /test/integration/production/pages/dynamic/no-ssr.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | 3 | const Hello = dynamic(import('../../components/hello1'), { ssr: false }) 4 | 5 | export default Hello 6 | -------------------------------------------------------------------------------- /examples/using-preact/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | export default () => ( 5 |
Hello World. About
6 | ) 7 | -------------------------------------------------------------------------------- /examples/with-flow/pages/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import Layout from '../components/layout' 4 | 5 | export default () => ( 6 | 7 |
Hello World.
8 |
9 | ) 10 | -------------------------------------------------------------------------------- /examples/with-prefetching/pages/about.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | 3 | export default () => ( 4 |
5 |
6 |

This is the ABOUT page.

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /examples/with-prefetching/pages/index.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | 3 | export default () => ( 4 |
5 |
6 |

This is the HOME page

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /test/integration/production/pages/dynamic/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 | No Chunk 6 |
7 | ) 8 | -------------------------------------------------------------------------------- /examples/with-prefetching/pages/contact.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | 3 | export default () => ( 4 |
5 |
6 |

This is the CONTACT page.

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /examples/with-prefetching/pages/features.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | 3 | export default () => ( 4 |
5 |
6 |

This is the FEATURES page.

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /examples/with-typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2015", 5 | "jsx": "react", 6 | "allowJs": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/using-inferno/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | export default () => ( 5 |
Hello World. About
6 | ) 7 | -------------------------------------------------------------------------------- /examples/with-styled-components/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "plugins": [ 6 | ["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ] 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /test/integration/basic/pages/empty-get-initial-props.js: -------------------------------------------------------------------------------- 1 | const EmptyInitialPropsPage = () => (
My Page
) 2 | EmptyInitialPropsPage.getInitialProps = () => null 3 | 4 | export default EmptyInitialPropsPage 5 | -------------------------------------------------------------------------------- /test/integration/production/pages/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 | About Page 6 |

Hello World

7 |
8 | ) 9 | -------------------------------------------------------------------------------- /examples/with-flow/pages/about.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import Layout from '../components/layout' 4 | 5 | export default () => ( 6 | 7 |
About us
8 |
9 | ) 10 | -------------------------------------------------------------------------------- /examples/with-jest/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 | 8 |

Hello World!

9 |
10 | ) 11 | -------------------------------------------------------------------------------- /examples/with-universal-configuration/env-config.js: -------------------------------------------------------------------------------- 1 | const prod = process.env.NODE_ENV === 'production' 2 | 3 | module.exports = { 4 | 'BACKEND_URL': prod ? 'https://api.example.com' : 'https://localhost:8080' 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/dist-dir/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | onDemandEntries: { 3 | // Make sure entries are not getting disposed. 4 | maxInactiveAge: 1000 * 60 * 60 5 | }, 6 | distDir: 'dist' 7 | } 8 | -------------------------------------------------------------------------------- /examples/with-flow/pages/contact.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import Layout from '../components/layout' 4 | 5 | export default () => ( 6 | 7 |
Contact
8 |
9 | ) 10 | -------------------------------------------------------------------------------- /examples/with-next-routes/routes.js: -------------------------------------------------------------------------------- 1 | const nextRoutes = require('next-routes') 2 | const routes = module.exports = nextRoutes() 3 | 4 | routes.add('blog', '/blog/:slug') 5 | routes.add('about', '/about-us/:foo(bar|baz)') 6 | -------------------------------------------------------------------------------- /examples/with-loading/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Header from '../components/Header' 3 | 4 | export default () => ( 5 |
6 |
7 |

Hello Next!

8 |
9 | ) 10 | -------------------------------------------------------------------------------- /test/integration/ondemand/pages/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 |

Index Page

6 | About Page 7 |
8 | ) 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | dist 3 | .next 4 | 5 | # dependencies 6 | node_modules 7 | 8 | # logs 9 | *.log 10 | 11 | # coverage 12 | .nyc_output 13 | coverage 14 | 15 | # test output 16 | test/**/out 17 | .DS_Store 18 | -------------------------------------------------------------------------------- /examples/with-fela/layout.js: -------------------------------------------------------------------------------- 1 | import { Provider } from 'react-fela' 2 | import felaRenderer from './fela-renderer' 3 | 4 | export default ({ children }) => 5 | 6 | {children} 7 | 8 | -------------------------------------------------------------------------------- /examples/with-fela/fela-renderer.js: -------------------------------------------------------------------------------- 1 | import { createRenderer } from 'fela' 2 | import webPreset from 'fela-preset-web' 3 | 4 | const felaRenderer = createRenderer({ 5 | plugins: [...webPreset] 6 | }) 7 | 8 | export default felaRenderer 9 | -------------------------------------------------------------------------------- /examples/with-react-ga/pages/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | import Layout from '../components/Layout' 3 | 4 | export default () => ( 5 |
Hello World. About
6 | ) 7 | -------------------------------------------------------------------------------- /examples/with-typescript/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import MyComponent from '../components/MyComponent' 3 | 4 | export default () => 5 |
6 |

Hello world

7 | 8 |
9 | -------------------------------------------------------------------------------- /examples/root-static-files/static/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://www.example.com/foo.html 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/with-styletron/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: function (config) { 3 | config.externals = config.externals || {} 4 | config.externals['styletron-server'] = 'styletron-server' 5 | return config 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/with-react-intl/lang/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "React Intl Next.js Example", 3 | "nav.home": "Home", 4 | "nav.about": "About", 5 | "description": "An example app integrating React Intl with Next.js", 6 | "greeting": "Hello, World!" 7 | } -------------------------------------------------------------------------------- /server/build/clean.js: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path' 2 | import del from 'del' 3 | import getConfig from '../config' 4 | 5 | export default function clean (dir) { 6 | const dist = getConfig(dir).distDir 7 | return del(resolve(dir, dist)) 8 | } 9 | -------------------------------------------------------------------------------- /examples/with-styled-components/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled from 'styled-components' 3 | 4 | const Title = styled.h1` 5 | color: red; 6 | font-size: 50px; 7 | ` 8 | 9 | export default () => My page 10 | -------------------------------------------------------------------------------- /test/integration/basic/pages/dynamic/no-ssr-custom-loading.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | 3 | const Hello = dynamic(import('../../components/hello1'), { 4 | ssr: false, 5 | loading: () => (

LOADING

) 6 | }) 7 | 8 | export default Hello 9 | -------------------------------------------------------------------------------- /examples/root-static-files/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 | 7 | ) 8 | -------------------------------------------------------------------------------- /examples/with-global-stylesheet/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('postcss-easy-import')({prefix: '_'}), // keep this first 4 | require('autoprefixer')({ /* ...options */ }) // so imports are auto-prefixed too 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /lib/shallow-equals.js: -------------------------------------------------------------------------------- 1 | export default function shallowEquals (a, b) { 2 | for (const i in a) { 3 | if (b[i] !== a[i]) return false 4 | } 5 | 6 | for (const i in b) { 7 | if (b[i] !== a[i]) return false 8 | } 9 | 10 | return true 11 | } 12 | -------------------------------------------------------------------------------- /test/integration/production/pages/dynamic/no-ssr-custom-loading.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | 3 | const Hello = dynamic(import('../../components/hello1'), { 4 | ssr: false, 5 | loading: () => (

LOADING

) 6 | }) 7 | 8 | export default Hello 9 | -------------------------------------------------------------------------------- /examples/nested-components/components/paragraph.js: -------------------------------------------------------------------------------- 1 | export default ({ children }) => ( 2 |

3 | {children} 4 | 10 |

11 | ) 12 | -------------------------------------------------------------------------------- /examples/shared-modules/pages/index.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | import Counter from '../components/Counter' 3 | 4 | export default () => ( 5 |
6 |
7 |

HOME PAGE is here!

8 | 9 |
10 | ) 11 | -------------------------------------------------------------------------------- /examples/with-react-intl/lang/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "React Intl Next.js Exemple", 3 | "nav.home": "Accueil", 4 | "nav.about": "À propos de nous", 5 | "description": "Un exemple d'application intégrant React Intl avec Next.js", 6 | "greeting": "Bonjour le monde!" 7 | } 8 | -------------------------------------------------------------------------------- /examples/with-styletron/layout.js: -------------------------------------------------------------------------------- 1 | import { StyletronProvider } from 'styletron-react' 2 | import getStyletron from './styletron' 3 | 4 | export default ({ children }) => ( 5 | 6 | {children} 7 | 8 | ) 9 | -------------------------------------------------------------------------------- /examples/custom-server/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | export default () => ( 5 | 9 | ) 10 | -------------------------------------------------------------------------------- /examples/shared-modules/pages/about.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | import Counter from '../components/Counter' 3 | 4 | export default () => ( 5 |
6 |
7 |

This is the about page.

8 | 9 |
10 | ) 11 | -------------------------------------------------------------------------------- /examples/with-antd-mobile/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "plugins": [ 6 | [ 7 | "import", 8 | { 9 | "libraryName": "antd-mobile" 10 | } 11 | ] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /examples/with-react-md/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: function (config) { 3 | if (config.resolve.alias) { 4 | delete config.resolve.alias['react'] 5 | delete config.resolve.alias['react-dom'] 6 | } 7 | return config 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/custom-server-express/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | export default () => ( 5 | 9 | ) 10 | -------------------------------------------------------------------------------- /examples/custom-server-hapi/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | export default () => ( 5 | 9 | ) 10 | -------------------------------------------------------------------------------- /examples/custom-server-koa/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | export default () => ( 5 | 9 | ) 10 | -------------------------------------------------------------------------------- /test/integration/basic/pages/finish-response.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | 3 | export default class extends Component { 4 | static getInitialProps ({ res }) { 5 | res.end('hi') 6 | } 7 | 8 | render () { 9 | return
hi
10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/integration/basic/pages/head.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Head from 'next/head' 3 | 4 | export default () =>
5 | 6 | 7 | 8 | 9 |

I can haz meta tags

10 |
11 | -------------------------------------------------------------------------------- /examples/with-antd-mobile/pages/index.js: -------------------------------------------------------------------------------- 1 | import { Component } from 'react' 2 | 3 | export default class Index extends Component { 4 | static async getInitialProps ({ res }) { 5 | res.setHeader('Location', '/home') 6 | res.statusCode = 302 7 | res.end() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/with-scoped-stylesheets-and-postcss/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('postcss-cssnext')(), 4 | require('postcss-modules')({ 5 | generateScopedName: '[local]-[hash:base64:5]' 6 | }), 7 | require('cssnano')() 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/basic/pages/nav/about.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 | 6 | Go Back 7 | 8 | 9 |

This is the about page.

10 |
11 | ) 12 | -------------------------------------------------------------------------------- /examples/with-dotenv/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel", 4 | ], 5 | "env": { 6 | "development": { 7 | "plugins": ["inline-dotenv"] 8 | }, 9 | "production": { 10 | "plugins": ["transform-inline-environment-variables"] 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/static/pages/about.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 |
6 | 7 | Go Back 8 | 9 |
10 |

This is the About page

11 |
12 | ) 13 | -------------------------------------------------------------------------------- /test/integration/static/pages/get-initial-props-with-no-query.js: -------------------------------------------------------------------------------- 1 | const Page = ({ query }) => ( 2 |
3 | { `Query is: ${query}` } 4 |
5 | ) 6 | 7 | Page.getInitialProps = ({ query }) => { 8 | return { query: JSON.stringify(query) } 9 | } 10 | 11 | export default Page 12 | -------------------------------------------------------------------------------- /examples/with-apollo-and-redux/lib/reducers.js: -------------------------------------------------------------------------------- 1 | export default { 2 | example: (state = {}, { type, payload }) => { 3 | switch (type) { 4 | case 'EXAMPLE_ACTION': 5 | return { 6 | ...state 7 | } 8 | default: 9 | return state 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/with-external-scoped-css/pre-processor.js: -------------------------------------------------------------------------------- 1 | const sass = require('node-sass') 2 | 3 | module.exports = (data, filename) => { 4 | return sass.renderSync({ 5 | data, 6 | file: filename, 7 | indentedSyntax: true, 8 | outputStyle: 'compressed' 9 | }).css.toString('utf8') 10 | } 11 | -------------------------------------------------------------------------------- /examples/with-styletron/pages/index.js: -------------------------------------------------------------------------------- 1 | import { styled } from 'styletron-react' 2 | import Page from '../layout' 3 | 4 | const Title = styled('div', { 5 | color: 'red', 6 | fontSize: '50px' 7 | }) 8 | 9 | export default () => ( 10 | 11 | My page 12 | 13 | ) 14 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/pages/about.js: -------------------------------------------------------------------------------- 1 | import Header from '../components/Header' 2 | import Counter from '../components/Counter' 3 | 4 | const About = () => ( 5 |
6 |
7 |

This is the about page.

8 | 9 |
10 | ) 11 | 12 | export default About 13 | -------------------------------------------------------------------------------- /test/integration/static/pages/button-link.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 | 12 | ) 13 | -------------------------------------------------------------------------------- /test/integration/static/pages/level1/about.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 |
6 | 7 | Go Back 8 | 9 |
10 |

This is the Level1 about page

11 |
12 | ) 13 | -------------------------------------------------------------------------------- /test/integration/static/pages/level1/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 |
6 | 7 | Go Back 8 | 9 |
10 |

This is the Level1 home page

11 |
12 | ) 13 | -------------------------------------------------------------------------------- /bench/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "next-bench", 3 | "scripts": { 4 | "build": "next build", 5 | "start": "npm run build && next start", 6 | "bench:stateless": "ab -c1 -n3000 http://0.0.0.0:3000/stateless", 7 | "bench:stateless-big": "ab -c1 -n500 http://0.0.0.0:3000/stateless-big" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/with-external-scoped-css/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ss from './index.sass' 3 | 4 | export const IndexPage = () => ( 5 |
6 | This is an example from scoped style in a outside CSS file {'<3'} 7 |
8 | ) 9 | 10 | export default IndexPage 11 | -------------------------------------------------------------------------------- /examples/with-jest/__tests__/__snapshots__/index.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`With Snapshot Testing App shows "Hello world!" 1`] = ` 4 |
7 |

10 | Hello World! 11 |

12 |
13 | `; 14 | -------------------------------------------------------------------------------- /examples/with-refnux/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-refnux", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "next": "next" 6 | }, 7 | "license": "ISC", 8 | "dependencies": { 9 | "next": "latest", 10 | "react": "^15.4.2", 11 | "react-dom": "^15.4.2", 12 | "refnux": "^1.3.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/basic/pages/dynamic/no-chunk.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | import Welcome from '../../components/welcome' 3 | 4 | const Welcome2 = dynamic(import('../../components/welcome')) 5 | 6 | export default () => ( 7 |
8 | 9 | 10 |
11 | ) 12 | -------------------------------------------------------------------------------- /examples/with-jest/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "development": { 4 | "presets": "next/babel" 5 | }, 6 | "production": { 7 | "presets": "next/babel" 8 | }, 9 | "test": { 10 | "presets": [ 11 | ["env", { "modules": "commonjs" }], 12 | "next/babel" 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/integration/production/pages/dynamic/no-chunk.js: -------------------------------------------------------------------------------- 1 | import dynamic from 'next/dynamic' 2 | import Welcome from '../../components/welcome' 3 | 4 | const Welcome2 = dynamic(import('../../components/welcome')) 5 | 6 | export default () => ( 7 |
8 | 9 | 10 |
11 | ) 12 | -------------------------------------------------------------------------------- /examples/with-amp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-amp", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-i18next/tools/startI18n.js: -------------------------------------------------------------------------------- 1 | import i18n from 'i18next' 2 | 3 | const startI18n = (file, lang) => i18n.init({ 4 | lng: lang, // active language http://i18next.com/translate/ 5 | fallbackLng: 'pt', 6 | resources: file, 7 | ns: ['common'], 8 | defaultNS: 'common', 9 | debug: false 10 | }) 11 | 12 | export default startI18n 13 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env", 4 | "react" 5 | ], 6 | "plugins": [ 7 | "transform-object-rest-spread", 8 | "transform-class-properties", 9 | "transform-runtime" 10 | ], 11 | "env": { 12 | "test": { 13 | "presets": [ 14 | "es2015", 15 | "./babel" 16 | ] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/basic-css/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-css", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-material-ui/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: (config) => { 3 | // Remove minifed react aliases for material-ui so production builds work 4 | if (config.resolve.alias) { 5 | delete config.resolve.alias.react 6 | delete config.resolve.alias['react-dom'] 7 | } 8 | 9 | return config 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/with-pretty-url-routing/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default function IndexPage () { 4 | return ( 5 |
6 |

Homepage

7 |
8 | Name: 9 | 10 |
11 |
12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /examples/head-elements/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "head-elements", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/hello-world/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/using-router/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "using-router", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-global-stylesheet/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import stylesheet from 'styles/index.scss' 4 | // or, if you work with plain css 5 | // import stylesheet from 'styles/index.css' 6 | 7 | export default () => 8 |
9 | 14 |
15 | ) 16 | -------------------------------------------------------------------------------- /examples/shared-modules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shared-modules", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/svg-components/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svg-components", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest" 11 | }, 12 | "devDependencies": { 13 | "babel-plugin-inline-react-svg": "^0.2.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-scoped-stylesheets-and-postcss/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Head from 'next/head' 3 | import {stylesheet, classNames} from './styles.css' 4 | 5 | export default () => ( 6 |

7 | 14 | 15 | ) 16 | -------------------------------------------------------------------------------- /examples/with-external-scoped-css/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["next/babel"], 3 | "plugins": [ 4 | [ 5 | "css-modules-transform", { 6 | "extensions": [".css", ".sass"], 7 | "append": [ "postcss-cssnext" ], 8 | "extractCss": "./static/css/bundle.css", 9 | "preprocessCss": "./pre-processor.js" 10 | } 11 | ] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /examples/with-react-intl/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ], 5 | "env": { 6 | "development": { 7 | "plugins": [ 8 | "react-intl" 9 | ] 10 | }, 11 | "production": { 12 | "plugins": [ 13 | ["react-intl", { 14 | "messagesDir": "lang/.messages/" 15 | }] 16 | ] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-material-ui-next/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-material-ui-next", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "material-ui": "next", 6 | "next": "latest", 7 | "react": "^15.5.4", 8 | "react-dom": "^15.5.4" 9 | }, 10 | "scripts": { 11 | "dev": "next", 12 | "build": "next build", 13 | "start": "next start" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-typescript", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "concurrently \"tsc --watch\" next" 6 | }, 7 | "dependencies": { 8 | "next": "latest" 9 | }, 10 | "devDependencies": { 11 | "@types/react": "^15.0.1", 12 | "concurrently": "^3.1.0", 13 | "typescript": "^2.1.5" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/integration/basic/components/hello-context.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import PropTypes from 'prop-types' 3 | 4 | export default class extends React.Component { 5 | static contextTypes = { 6 | data: PropTypes.object 7 | } 8 | 9 | render () { 10 | const { data } = this.context 11 | return ( 12 |

{data.title}
13 | ) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-glamor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-glamor", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "glamor": "^2.20.24", 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | }, 15 | "license": "ISC" 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-higher-order-component/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-higher-order-component", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-prefetching/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-prefetching", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "author": "", 15 | "license": "ISC" 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-styled-jsx-postcss/babel-preset.js: -------------------------------------------------------------------------------- 1 | const nextBabelPreset = require('next/babel') 2 | 3 | nextBabelPreset.plugins = nextBabelPreset.plugins.map(plugin => { 4 | if (!Array.isArray(plugin) && plugin.indexOf('styled-jsx/babel') !== -1) { 5 | return require.resolve('styled-jsx-postcss/babel') 6 | } 7 | return plugin 8 | }) 9 | 10 | module.exports = nextBabelPreset 11 | -------------------------------------------------------------------------------- /test/integration/production/components/hello-context.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import PropTypes from 'prop-types' 3 | 4 | export default class extends React.Component { 5 | static contextTypes = { 6 | data: PropTypes.object 7 | } 8 | 9 | render () { 10 | const { data } = this.context 11 | return ( 12 |
{data.title}
13 | ) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/data-fetch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "data-fetch", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "isomorphic-fetch": "^2.2.1", 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | }, 15 | "license": "ISC" 16 | } 17 | -------------------------------------------------------------------------------- /examples/shared-modules/components/Header.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 | 6 | Home 7 | 8 | 9 | 10 | About 11 | 12 |
13 | ) 14 | 15 | const styles = { 16 | a: { 17 | marginRight: 10 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-sw-precache/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-sw-precache", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "build": "next build", 6 | "start": "NODE_ENV=production node server.js" 7 | }, 8 | "dependencies": { 9 | "next": "latest", 10 | "react": "^15.4.2", 11 | "react-dom": "^15.4.2", 12 | "sw-precache-webpack-plugin": "^0.11.3" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/with-cxs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-cxs", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "cxs": "^3.0.0", 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | }, 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/Header.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 |
5 | 6 | Home 7 | 8 | 9 | 10 | About 11 | 12 |
13 | ) 14 | 15 | const styles = { 16 | a: { 17 | marginRight: 10 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-react-helmet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-react-helmet", 3 | "license": "ISC", 4 | "version": "1.0.0", 5 | "scripts": { 6 | "dev": "next", 7 | "build": "next build", 8 | "start": "next start" 9 | }, 10 | "dependencies": { 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2", 14 | "react-helmet": "^4.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-react-uwp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-react-uwp", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "babel-core": "^6.25.0", 6 | "next": "latest", 7 | "react": "^15.5.4", 8 | "react-dom": "^15.5.4", 9 | "react-uwp": "^1.0.9" 10 | }, 11 | "scripts": { 12 | "dev": "next", 13 | "build": "next build", 14 | "start": "next start" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-next-routes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-next-routes", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "next-routes": "^1.0.17", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-semantic-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-semantic-ui", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2", 13 | "semantic-ui-react": "^0.68.0" 14 | }, 15 | "license": "ISC" 16 | } 17 | -------------------------------------------------------------------------------- /examples/ssr-caching/pages/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 | 9 | ) 10 | -------------------------------------------------------------------------------- /examples/with-aphrodite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-aphrodite", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "aphrodite": "^1.1.0", 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | }, 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-react-ga/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-react-ga", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2", 13 | "react-ga": "2.2.0" 14 | }, 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /test/integration/basic/pages/nav/redirect.js: -------------------------------------------------------------------------------- 1 | import Router from 'next/router' 2 | 3 | const Page = () => ( 4 |

This is the page

5 | ) 6 | 7 | Page.getInitialProps = (ctx) => { 8 | if (ctx.res) { 9 | ctx.res.writeHead(302, { Location: '/nav/about' }) 10 | ctx.res.end() 11 | } else { 12 | Router.push('/nav/about') 13 | } 14 | 15 | return {} 16 | } 17 | 18 | export default Page 19 | -------------------------------------------------------------------------------- /test/integration/static/pages/dynamic-imports.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | import dynamic from 'next/dynamic' 3 | 4 | const DynamicComponent = dynamic(import('../components/hello')) 5 | 6 | export default () => ( 7 |
8 |
9 | 10 | Go Back 11 | 12 |
13 | 14 |
15 | ) 16 | -------------------------------------------------------------------------------- /examples/custom-server-express/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-server-express", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "express": "^4.14.0", 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/parameterized-routing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parameterized-routing", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "path-match": "1.2.4", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/parameterized-routing/pages/index.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | export default () => ( 4 | 9 | ) 10 | -------------------------------------------------------------------------------- /examples/with-glamorous/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-glamorous", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "glamor": "^2.20.24", 11 | "glamorous": "^1.0.0", 12 | "next": "^2.0.1", 13 | "react": "^15.4.2", 14 | "react-dom": "^15.4.2" 15 | }, 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-material-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-material-ui", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "material-ui": "^0.18.0", 6 | "next": "latest", 7 | "react": "^15.5.4", 8 | "react-dom": "^15.5.4", 9 | "react-tap-event-plugin": "^2.0.1" 10 | }, 11 | "scripts": { 12 | "dev": "next", 13 | "build": "next build", 14 | "start": "next start" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-url-object-routing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-url-object-routing", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "path-match": "1.2.4", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/ssr-caching/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ssr-caching", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "express": "^4.14.0", 11 | "lru-cache": "^4.0.2", 12 | "next": "latest", 13 | "react": "^15.4.2", 14 | "react-dom": "^15.4.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-apollo/pages/index.js: -------------------------------------------------------------------------------- 1 | import App from '../components/App' 2 | import Header from '../components/Header' 3 | import Submit from '../components/Submit' 4 | import PostList from '../components/PostList' 5 | import withData from '../lib/withData' 6 | 7 | export default withData((props) => ( 8 | 9 |
10 | 11 | 12 | 13 | )) 14 | -------------------------------------------------------------------------------- /examples/shared-modules/components/Counter.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | let count = 0 4 | 5 | export default class Counter extends React.Component { 6 | add () { 7 | count += 1 8 | this.forceUpdate() 9 | } 10 | 11 | render () { 12 | return ( 13 |
14 |

Count is: {count}

15 | 16 |
17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/using-preact/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "using-preact", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "module-alias": "^2.0.0", 11 | "next": "latest", 12 | "preact": "^7.2.0", 13 | "preact-compat": "^3.14.0" 14 | }, 15 | "license": "ISC" 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-ant-design/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-ant-design", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "antd": "^2.10.2", 11 | "babel-plugin-import": "^1.1.1", 12 | "next": "latest", 13 | "react": "^15.5.4", 14 | "react-dom": "^15.5.4" 15 | }, 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /examples/custom-server-koa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-server-koa", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "koa": "^2.0.1", 11 | "koa-router": "^7.1.0", 12 | "next": "latest", 13 | "react": "^15.4.2", 14 | "react-dom": "^15.4.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/using-inferno/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: function (config, { dev }) { 3 | // For the development version, we'll use React. 4 | // Because, it support react hot loading and so on. 5 | if (dev) { 6 | return config 7 | } 8 | 9 | config.resolve.alias = { 10 | 'react': 'inferno-compat', 11 | 'react-dom': 'inferno-compat' 12 | } 13 | return config 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-apollo-and-redux/pages/index.js: -------------------------------------------------------------------------------- 1 | import App from '../components/App' 2 | import Header from '../components/Header' 3 | import Submit from '../components/Submit' 4 | import PostList from '../components/PostList' 5 | import withData from '../lib/withData' 6 | 7 | export default withData((props) => ( 8 | 9 |
10 | 11 | 12 | 13 | )) 14 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/components/Counter.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | let count = 0 4 | 5 | export default class Counter extends React.Component { 6 | add () { 7 | count += 1 8 | this.forceUpdate() 9 | } 10 | 11 | render () { 12 | return ( 13 |
14 |

Count is: {count}

15 | 16 |
17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | addons: 4 | apt: 5 | sources: 6 | - google-chrome 7 | packages: 8 | - google-chrome-stable 9 | language: node_js 10 | node_js: 11 | - "4" 12 | - "6" 13 | cache: 14 | directories: 15 | - node_modules 16 | before_install: 17 | - rm yarn.lock 18 | - export DISPLAY=:99.0 19 | - sh -e /etc/init.d/xvfb start 20 | - sleep 3 21 | after_script: npm run coveralls 22 | -------------------------------------------------------------------------------- /examples/with-fela/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-fela", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "fela": "^5.0.1", 11 | "fela-dom": "5.0.2", 12 | "fela-preset-web": "^5.0.2", 13 | "next": "latest", 14 | "react": "^15.4.2", 15 | "react-dom": "^15.4.2", 16 | "react-fela": "^5.0.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-global-stylesheet/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | [ 4 | "module-resolver", { 5 | "root": ["."], 6 | "alias": { 7 | "styles": "./styles" 8 | }, 9 | "cwd": "babelrc" 10 | }], 11 | [ 12 | "wrap-in-js", 13 | { 14 | "extensions": ["css$", "scss$"] 15 | } 16 | ] 17 | ], 18 | "presets": [ 19 | "next/babel" 20 | ], 21 | "ignore": [] 22 | } 23 | -------------------------------------------------------------------------------- /examples/with-styletron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-styletron", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2", 13 | "styletron-client": "^2.2.0", 14 | "styletron-react": "^2.2.1", 15 | "styletron-server": "^2.2.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/integration/basic/components/welcome.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class Welcome extends React.Component { 4 | state = { name: null } 5 | 6 | componentDidMount () { 7 | const { name } = this.props 8 | this.setState({ name }) 9 | } 10 | 11 | render () { 12 | const { name } = this.state 13 | if (!name) return null 14 | 15 | return ( 16 |

Welcome, {name}

17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/integration/production/components/welcome.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class Welcome extends React.Component { 4 | state = { name: null } 5 | 6 | componentDidMount () { 7 | const { name } = this.props 8 | this.setState({ name }) 9 | } 10 | 11 | render () { 12 | const { name } = this.state 13 | if (!name) return null 14 | 15 | return ( 16 |

Welcome, {name}

17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-i18next/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-i18next", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "i18next": "^7.1.3", 11 | "isomorphic-fetch": "^2.2.1", 12 | "next": "latest", 13 | "react": "^15.4.2", 14 | "react-dom": "^15.4.2", 15 | "react-i18next": "^2.2.1" 16 | }, 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-loading/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-loading", 3 | "version": "1.0.0", 4 | "description": "This example features:", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "next", 8 | "build": "next build", 9 | "start": "next start" 10 | }, 11 | "dependencies": { 12 | "next": "latest", 13 | "nprogress": "^0.2.0", 14 | "react": "^15.4.2", 15 | "react-dom": "^15.4.2" 16 | }, 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-url-object-routing/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | 4 | const href = { 5 | pathname: '/about', 6 | query: { name: 'next' } 7 | } 8 | 9 | const as = { 10 | pathname: '/about/next', 11 | hash: 'title-1' 12 | } 13 | 14 | export default () => ( 15 |
16 |

Home page

17 | 18 | Go to /about/next 19 | 20 |
21 | ) 22 | -------------------------------------------------------------------------------- /examples/custom-server-hapi/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-server-hapi", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "hapi": "^16.1.0", 11 | "next": "latest", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2", 14 | "good": "^7.1.0", 15 | "good-console": "^6.2.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-refnux/store/getStore.js: -------------------------------------------------------------------------------- 1 | import { createStore } from 'refnux' 2 | 3 | const storeInitialState = { counter: 0, key: 'value' } 4 | 5 | const getStore = () => { 6 | let store = null 7 | if (typeof window === 'undefined') { 8 | store = createStore(storeInitialState) 9 | } else { 10 | store = window.store || createStore(storeInitialState) 11 | window.store = store 12 | } 13 | return store 14 | } 15 | 16 | export default getStore 17 | -------------------------------------------------------------------------------- /examples/basic-css/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |
3 |

Hello World

4 | 16 |
17 | ) 18 | -------------------------------------------------------------------------------- /examples/using-inferno/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "using-inferno", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "inferno": "^1.4.0", 11 | "inferno-compat": "^1.4.0", 12 | "inferno-server": "^1.4.0", 13 | "module-alias": "^2.0.0", 14 | "next": "latest" 15 | }, 16 | "license": "MIT" 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-styled-components/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-styled-components", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "babel-plugin-styled-components": "^1.1.5", 11 | "next": "latest", 12 | "react": "^15.6.1", 13 | "react-dom": "^15.6.1", 14 | "styled-components": "^2.1.0" 15 | }, 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-webpack-bundle-analyzer/next.config.js: -------------------------------------------------------------------------------- 1 | const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') 2 | const { ANALYZE } = process.env 3 | 4 | module.exports = { 5 | webpack: function (config) { 6 | if (ANALYZE) { 7 | config.plugins.push(new BundleAnalyzerPlugin({ 8 | analyzerMode: 'server', 9 | analyzerPort: 8888, 10 | openAnalyzer: true 11 | })) 12 | } 13 | 14 | return config 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/integration/basic/lib/cdm.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react' 2 | 3 | export default class extends Component { 4 | constructor (props) { 5 | super(props) 6 | 7 | this.state = { 8 | mounted: false 9 | } 10 | } 11 | 12 | componentDidMount () { 13 | this.setState({mounted: true}) 14 | } 15 | 16 | render () { 17 | return

ComponentDidMount {this.state.mounted ? 'executed on client' : 'not executed'}.

18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/integration/basic/pages/async-props.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class AsyncProps extends React.Component { 4 | static async getInitialProps () { 5 | return await fetchData() 6 | } 7 | 8 | render () { 9 | return

{this.props.name}

10 | } 11 | } 12 | 13 | function fetchData () { 14 | const p = new Promise(resolve => { 15 | setTimeout(() => resolve({ name: 'Diego Milito' }), 10) 16 | }) 17 | return p 18 | } 19 | -------------------------------------------------------------------------------- /examples/using-preact/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: function (config, { dev }) { 3 | // For the development version, we'll use React. 4 | // Because, it support react hot loading and so on. 5 | if (dev) { 6 | return config 7 | } 8 | 9 | config.resolve.alias = { 10 | 'react': 'preact-compat/dist/preact-compat', 11 | 'react-dom': 'preact-compat/dist/preact-compat' 12 | } 13 | 14 | return config 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-dotenv/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-dotenv", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2", 13 | "babel-plugin-inline-dotenv": "^1.1.1", 14 | "babel-plugin-transform-inline-environment-variables": "^0.1.1" 15 | }, 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-refnux/helpers/getStore.js: -------------------------------------------------------------------------------- 1 | import { createStore } from 'refnux' 2 | 3 | let storeMemoized = null 4 | 5 | const getStore = (initialState) => { 6 | let store = null 7 | if (typeof window === 'undefined') { 8 | store = createStore(initialState) 9 | } else { 10 | if (!storeMemoized) { 11 | storeMemoized = createStore(initialState) 12 | } 13 | store = storeMemoized 14 | } 15 | return store 16 | } 17 | 18 | export default getStore 19 | -------------------------------------------------------------------------------- /examples/with-universal-configuration/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-universal-configuration", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-dom": "^15.4.2" 13 | }, 14 | "devDependencies": { 15 | "babel-plugin-transform-define": "^1.2.0" 16 | }, 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /examples/using-router/pages/error.js: -------------------------------------------------------------------------------- 1 | import {Component} from 'react' 2 | import Header from '../components/Header' 3 | import Router from 'next/router' 4 | 5 | export default class extends Component { 6 | static getInitialProps () { 7 | console.log(Router.pathname) 8 | return {} 9 | } 10 | 11 | render () { 12 | return ( 13 |
14 |
15 |

This should not be rendered via SSR

16 |
17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/integration/basic/test/misc.js: -------------------------------------------------------------------------------- 1 | /* global describe, test, expect */ 2 | 3 | export default function (context) { 4 | describe('Misc', () => { 5 | test('finishes response', async () => { 6 | const res = { 7 | finished: false, 8 | end () { 9 | this.finished = true 10 | } 11 | } 12 | const html = await context.app.renderToHTML({}, res, '/finish-response', {}) 13 | expect(html).toBeFalsy() 14 | }) 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /examples/nested-components/components/post.js: -------------------------------------------------------------------------------- 1 | export default ({ title, children }) => ( 2 |
3 |

{ title }

4 | { children } 5 | 18 |
19 | ) 20 | -------------------------------------------------------------------------------- /examples/with-antd-mobile/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-antd-mobile", 3 | "version": "1.1.0", 4 | "dependencies": { 5 | "antd-mobile": "1.4.0", 6 | "babel-plugin-import": "^1.2.1", 7 | "next": "latest", 8 | "react": "^15.6.1", 9 | "react-dom": "^15.6.1", 10 | "require-hacker": "^3.0.0", 11 | "svg-sprite-loader": "0.3.1" 12 | }, 13 | "scripts": { 14 | "dev": "next", 15 | "build": "next build", 16 | "start": "next start" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-next-routes/server.js: -------------------------------------------------------------------------------- 1 | const { createServer } = require('http') 2 | const next = require('next') 3 | const routes = require('./routes') 4 | 5 | const dev = process.env.NODE_ENV !== 'production' 6 | const app = next({ dev }) 7 | const handler = routes.getRequestHandler(app) 8 | 9 | app.prepare() 10 | .then(() => { 11 | createServer(handler) 12 | .listen(3000, (err) => { 13 | if (err) throw err 14 | console.log('> Ready on http://localhost:3000') 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /examples/with-react-ga/components/Layout.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { initGA, logPageView } from '../utils/analytics' 3 | 4 | export default class Layout extends React.Component { 5 | componentDidMount () { 6 | if (!window.GA_INITIALIZED) { 7 | initGA() 8 | window.GA_INITIALIZED = true 9 | } 10 | logPageView() 11 | } 12 | render () { 13 | return ( 14 |
15 | {this.props.children} 16 |
17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-react-uwp/components/ThemeWrapper.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Theme from 'react-uwp/Theme' 3 | 4 | export class ThemeWrapper extends Component { 5 | render () { 6 | const { children, style, ...props } = this.props 7 | return ( 8 | 9 | {children} 10 | 11 | ) 12 | } 13 | } 14 | 15 | export default ThemeWrapper 16 | -------------------------------------------------------------------------------- /examples/with-pretty-url-routing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-pretty-url-routing", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "express": "^4.15.2", 11 | "next": "latest", 12 | "next-url-prettifier": "^1.0.2", 13 | "prop-types": "^15.5.6", 14 | "react": "^15.4.2", 15 | "react-dom": "^15.4.2" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-styled-jsx-postcss/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-styled-jsx-postcss", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "postcss-cssnext": "^2.9.0", 12 | "react": "^15.4.2", 13 | "react-dom": "^15.4.2", 14 | "styled-jsx-postcss": "^0.1.5" 15 | }, 16 | "author": "Giuseppe Gurgone", 17 | "license": "MIT" 18 | } 19 | -------------------------------------------------------------------------------- /examples/ssr-caching/pages/blog.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class extends React.Component { 4 | static getInitialProps ({ query: { id } }) { 5 | return { id } 6 | } 7 | 8 | render () { 9 | return
10 |

My {this.props.id} blog post

11 |

12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 13 | tempor incididunt ut labore et dolore magna aliqua. 14 |

15 |
16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-react-md/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-react-md", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "react": "^15.4.2", 12 | "react-addons-css-transition-group": "^15.4.2", 13 | "react-addons-transition-group": "^15.4.2", 14 | "react-dom": "^15.4.2", 15 | "react-md": "^1.0.1" 16 | }, 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /test/integration/basic/pages/stateful.js: -------------------------------------------------------------------------------- 1 | 2 | import React, { Component } from 'react' 3 | 4 | export default class Statefull extends Component { 5 | constructor (props) { 6 | super(props) 7 | 8 | this.state = { answer: null } 9 | } 10 | 11 | componentWillMount () { 12 | this.setState({ answer: 42 }) 13 | } 14 | 15 | render () { 16 | return ( 17 |
18 |

The answer is {this.state.answer}

19 |
20 | ) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/parameterized-routing/pages/blog.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class extends React.Component { 4 | static getInitialProps ({ query: { id } }) { 5 | return { id } 6 | } 7 | 8 | render () { 9 | return
10 |

My {this.props.id} blog post

11 |

12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 13 | tempor incididunt ut labore et dolore magna aliqua. 14 |

15 |
16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/with-apollo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-apollo", 3 | "version": "2.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "graphql": "^0.9.3", 11 | "isomorphic-fetch": "^2.2.1", 12 | "next": "latest", 13 | "prop-types": "^15.5.8", 14 | "react": "^15.5.4", 15 | "react-dom": "^15.5.4", 16 | "react-apollo": "^1.1.3" 17 | }, 18 | "author": "", 19 | "license": "ISC" 20 | } 21 | -------------------------------------------------------------------------------- /examples/with-dynamic-import/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-dynamic-import", 3 | "version": "1.0.0", 4 | "description": "This example features:", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "next", 8 | "build": "next build", 9 | "start": "next start" 10 | }, 11 | "dependencies": { 12 | "async-reactor": "^1.1.1", 13 | "next": "^3.0.0-beta13", 14 | "react": "^15.4.2", 15 | "react-dom": "^15.4.2" 16 | }, 17 | "author": "", 18 | "license": "ISC" 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-react-toolbox/pages/index.js: -------------------------------------------------------------------------------- 1 | import ThemeProvider from 'react-toolbox/lib/ThemeProvider' 2 | import theme from '../static/theme' 3 | import Head from 'next/head' 4 | 5 | import Button from 'react-toolbox/lib/button/Button' 6 | 7 | export default () => ( 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | ) 17 | -------------------------------------------------------------------------------- /examples/with-socket.io/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-socket.io", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "express": "^4.15.2", 6 | "isomorphic-fetch": "^2.2.1", 7 | "next": "latest", 8 | "react": "^15.5.4", 9 | "react-dom": "^15.5.4", 10 | "socket.io": "^1.7.3", 11 | "socket.io-client": "^1.7.3" 12 | }, 13 | "scripts": { 14 | "dev": "node server.js", 15 | "build": "next build", 16 | "start": "NODE_ENV=production node server.js" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/custom-server-hapi/next-wrapper.js: -------------------------------------------------------------------------------- 1 | const pathWrapper = (app, pathName, opts) => ({ raw, query }, hapiReply) => 2 | app.renderToHTML(raw.req, raw.res, pathName, query, opts) 3 | .then(hapiReply) 4 | 5 | const defaultHandlerWrapper = app => { 6 | const handler = app.getRequestHandler() 7 | return ({ raw, url }, hapiReply) => 8 | handler(raw.req, raw.res, url) 9 | .then(() => { 10 | hapiReply.close(false) 11 | }) 12 | } 13 | module.exports = { pathWrapper, defaultHandlerWrapper } 14 | -------------------------------------------------------------------------------- /examples/with-loading/pages/about.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Header from '../components/Header' 3 | 4 | export default class About extends Component { 5 | // Add some delay 6 | static async getInitialProps () { 7 | await new Promise((resolve) => { 8 | setTimeout(resolve, 500) 9 | }) 10 | return {} 11 | } 12 | 13 | render () { 14 | return ( 15 |
16 |
17 |

This is about Next!

18 |
19 | ) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/with-glamor/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { style, rehydrate } from 'glamor' 3 | 4 | // Adds server generated styles to glamor cache. 5 | // Has to run before any `style()` calls 6 | // '__NEXT_DATA__.ids' is set in '_document.js' 7 | if (typeof window !== 'undefined') { 8 | rehydrate(window.__NEXT_DATA__.ids) 9 | } 10 | 11 | export default () =>

My page

12 | 13 | const styles = { 14 | title: style({ 15 | color: 'red', 16 | fontSize: 50 17 | }) 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-redux/components/Page.js: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | import { connect } from 'react-redux' 3 | import Clock from './Clock' 4 | import AddCount from './AddCount' 5 | 6 | export default connect(state => state)(({ title, linkTo, lastUpdate, light }) => { 7 | return ( 8 |
9 |

{title}

10 | 11 | 12 | 15 |
16 | ) 17 | }) 18 | -------------------------------------------------------------------------------- /examples/with-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-jest", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "next": "latest", 6 | "react": "^15.5.4", 7 | "react-dom": "^15.5.4" 8 | }, 9 | "devDependencies": { 10 | "enzyme": "^2.8.2", 11 | "jest": "^20.0.0", 12 | "react-addons-test-utils": "^15.5.1", 13 | "react-test-renderer": "^15.5.4" 14 | }, 15 | "scripts": { 16 | "test": "jest", 17 | "dev": "next", 18 | "build": "next build", 19 | "start": "next start" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/with-redux/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-redux", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "next": "latest", 11 | "next-redux-wrapper": "^1.0.0", 12 | "react": "^15.4.2", 13 | "redux-devtools-extension": "^2.13.2", 14 | "react-dom": "^15.4.2", 15 | "react-redux": "^5.0.1", 16 | "redux": "^3.6.0", 17 | "redux-thunk": "^2.1.0" 18 | }, 19 | "license": "ISC" 20 | } 21 | -------------------------------------------------------------------------------- /examples/with-antd-mobile/components/Layout.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import { LocaleProvider } from 'antd-mobile' 3 | import enUS from 'antd-mobile/lib/locale-provider/en_US' 4 | 5 | export default class Layout extends Component { 6 | render () { 7 | const { language, children } = this.props 8 | const locale = language.substr(0, 2) === 'en' ? enUS : undefined 9 | 10 | return ( 11 | 12 | {children} 13 | 14 | ) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/integration/basic/pages/nav/as-path-using-router.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Router from 'next/router' 3 | 4 | export default class extends React.Component { 5 | constructor (...args) { 6 | super(...args) 7 | this.state = {} 8 | } 9 | 10 | componentDidMount () { 11 | const asPath = Router.asPath 12 | this.setState({ asPath }) 13 | } 14 | 15 | render () { 16 | return ( 17 |
18 | {this.state.asPath} 19 |
20 | ) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/with-loading/pages/forever.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Header from '../components/Header' 3 | 4 | export default class Forever extends Component { 5 | // Add some delay 6 | static async getInitialProps () { 7 | await new Promise((resolve) => { 8 | setTimeout(resolve, 3000) 9 | }) 10 | return {} 11 | } 12 | 13 | render () { 14 | return ( 15 |
16 |
17 |

This page was rendered for a while!

18 |
19 | ) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/with-mobx/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-mobx", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "node server.js", 6 | "build": "next build", 7 | "start": "NODE_ENV=production node server.js" 8 | }, 9 | "dependencies": { 10 | "mobx": "^2.7.0", 11 | "mobx-react": "^4.0.4", 12 | "next": "latest", 13 | "react": "^15.4.2", 14 | "react-dom": "^15.4.2" 15 | }, 16 | "license": "ISC", 17 | "devDependencies": { 18 | "babel-plugin-transform-decorators-legacy": "^1.3.4" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/with-webpack-bundle-analyzer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-webpack-bundle-analyzer", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start", 8 | "analyze": "cross-env ANALYZE=1 next build" 9 | }, 10 | "dependencies": { 11 | "next": "latest", 12 | "cross-env": "^5.0.1", 13 | "faker": "^4.1.0", 14 | "react": "^15.6.1", 15 | "react-dom": "^15.6.1", 16 | "webpack-bundle-analyzer": "^2.8.2" 17 | }, 18 | "license": "ISC" 19 | } 20 | -------------------------------------------------------------------------------- /examples/with-sw-precache/next.config.js: -------------------------------------------------------------------------------- 1 | const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin') 2 | 3 | module.exports = { 4 | webpack: (config) => { 5 | config.plugins.push( 6 | new SWPrecacheWebpackPlugin({ 7 | verbose: true, 8 | staticFileGlobsIgnorePatterns: [/\.next\//], 9 | runtimeCaching: [ 10 | { 11 | handler: 'networkFirst', 12 | urlPattern: /^https?.*/ 13 | } 14 | ] 15 | }) 16 | ) 17 | 18 | return config 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/with-custom-babel-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-custom-babel-config", 3 | "version": "1.0.0", 4 | "description": "This example features:", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "next", 8 | "build": "next build", 9 | "start": "next start" 10 | }, 11 | "dependencies": { 12 | "next": "latest", 13 | "react": "^15.4.2", 14 | "react-dom": "^15.4.2" 15 | }, 16 | "author": "", 17 | "license": "ISC", 18 | "devDependencies": { 19 | "babel-preset-stage-0": "^6.16.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/with-higher-order-component/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import withApp from '../components/withApp' 3 | 4 | class Index extends React.Component { 5 | static getInitialProps (context) { 6 | const { isServer } = context 7 | return { isServer } 8 | } 9 | render () { 10 | const { greeting } = this.props 11 | return ( 12 |
13 |

Index page

14 |

{greeting}

15 |
16 | ) 17 | } 18 | } 19 | 20 | export default withApp(Index) 21 | -------------------------------------------------------------------------------- /examples/with-apollo-and-redux/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-apollo-and-redux", 3 | "version": "2.0.0", 4 | "scripts": { 5 | "dev": "next", 6 | "build": "next build", 7 | "start": "next start" 8 | }, 9 | "dependencies": { 10 | "graphql": "^0.9.3", 11 | "isomorphic-fetch": "^2.2.1", 12 | "next": "latest", 13 | "prop-types": "^15.5.8", 14 | "react": "^15.5.4", 15 | "react-apollo": "^1.1.3", 16 | "react-dom": "^15.5.4", 17 | "redux": "^3.6.0" 18 | }, 19 | "author": "", 20 | "license": "ISC" 21 | } 22 | -------------------------------------------------------------------------------- /examples/with-antd-mobile/pages/_document.js: -------------------------------------------------------------------------------- 1 | import Document, { Head, Main, NextScript } from 'next/document' 2 | 3 | export default class extends Document { 4 | render () { 5 | return ( 6 | 7 | 8 |