You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you need state, lifecycle hooks or **initial data population** you can export a `React.Component` (instead of a stateless function, like shown above):
143
148
144
149
```jsx
@@ -237,10 +242,10 @@ _Note: in order to programmatically change the route without triggering navigati
Typically you start your next server with `next start`. It's possible, however, to start a server 100% programmatically in order to customize routes, use route patterns, etc
Pages in `Next.js` skip the definition of the surrounding document's markup. For example, you never include `<html>`, `<body>`, etc. But we still make it possible to override that:
For custom advanced behavior of Next.js, you can create a `next.config.js` in the root of your project directory (next to `pages/` and `package.json`).
Download the example (or clone the repo)[https://github.com/zeit/next.js.git]:
7
+
8
+
```bash
9
+
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/data-fetch
10
+
cd data-fetch
11
+
```
12
+
13
+
Install it and run:
14
+
15
+
```bash
16
+
npm install
17
+
npm run dev
18
+
```
19
+
20
+
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
21
+
22
+
```bash
23
+
now
24
+
```
25
+
26
+
## The idea behind the example
27
+
28
+
Next.js was conceived to make it easy to create universal apps. That's why fetching data
29
+
on the server and the client when necessary it's so easy with Next.
30
+
31
+
Using `getInitialProps` we will fetch data in the server for SSR and then in the client only when the component is re-mounted but not in the first paint.
0 commit comments