Skip to content
Dashboard
The "Hello World" of Next.js
$ npm install next --save
$ mkdir pages

import React from 'react'
export default () => <div>Hello world!</div>

{
"scripts": {
"dev": "next"
}
}

$ npm run dev

Link to headingBackground

Link to headingZero setup. Use the filesystem as an API

import React from 'react'
export default () => <marquee>Hello world</marquee>

import React from 'react'
export default () => <h1>About us</h1>

$ npm run dev

Link to headingOnly JavaScript. Everything is a function

import React from 'react'
import Head from 'next/head'
export default () => (
<div>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<h1>Hi. I'm mobile-ready!</h1>
</div>
)

import React from 'react'
import css from 'next/css'
export default () => <p className={style}>Hi there!</p>
const style = css({
color: 'red',
':hover': {
color: 'blue'
},
'@media (max-width: 500px)': {
color: 'rebeccapurple'
}
})

Link to headingAutomatic server rendering and code splitting

import React from 'react'
import d3 from 'd3'
import jQuery from 'jquery'

Link to headingData fetching is up to the developer

import React from 'react'
import 'isomorphic-fetch'
export default class extends React.Component {
static async getInitialProps () {
const res = await fetch('https://api.company.com/user/123')
const data = await res.json()
return { username: data.profile.username }
}
}

static async getInitialProps ({ res }) {
return res
? { userAgent: res.headers['user-agent'] }
: { userAgent: navigator.userAgent }
}

Link to headingAnticipation is the key to performance

Link to headingSimple deployment

{
"name": "my-app",
"dependencies": {
"next": "*"
},
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
}
}