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
Copy file name to clipboardExpand all lines: Readme.md
+17-14Lines changed: 17 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,16 @@
1
1
# next.js
2
2
3
-
`Next.js` is a minimalistic framework for server-rendered React applications.
3
+
Next.js is a minimalistic framework for server-rendered React applications.
4
4
5
5
## How to use
6
6
7
-
The file-system is the main API. Every `.js` file becomes a route that gets automatically processed and rendered.
7
+
Install it:
8
+
9
+
```
10
+
$ npm install next --save
11
+
```
12
+
13
+
After that, the file-system is the main API. Every `.js` file becomes a route that gets automatically processed and rendered.
8
14
9
15
Populate `./pages/index.js` inside your project:
10
16
@@ -83,7 +89,7 @@ export default () => (
83
89
)
84
90
```
85
91
86
-
### Lifecycle components
92
+
### Component lifecycle
87
93
88
94
When you need state, lifecycle hooks or **initial data population** you can export a `React.Component`:
89
95
@@ -219,16 +225,14 @@ Yes and No.
219
225
Yes in that both make your life easier.
220
226
221
227
No in that it enforces a _structure_ so that we can do more advanced things like:
222
-
- Server side rendering
223
-
- Automatic code splitting
228
+
- Server side rendering
229
+
- Automatic code splitting
224
230
225
231
In addition, Next.js provides two built-in features that are critical for every single website:
226
-
- Routing with lazy component loading: `<Link>` (by importing `next/link`)
227
-
- A way for components to alter `<head>`: `<Head>` (by importing `next/head`)
228
-
229
-
Next is not suitable right now for creating reusable components that every single React app can use. But we consider that a feature, since your re-usable components should live in separate repositories and then `import`ed.
232
+
- Routing with lazy component loading: `<Link>` (by importing `next/link`)
233
+
- A way for components to alter `<head>`: `<Head>` (by importing `next/head`)
230
234
231
-
In the future, we might consider a `next export` feature that produces a re-usable build of a component, to take advantage of Glamor and our simple and easy-to-use build system.
235
+
If you want to create re-usable React components that you can embed in your Next.js app or other React applications, using `create-react-app` is a great idea. You can later `import` it and keep your codebase clean!
232
236
233
237
</details>
234
238
@@ -241,8 +245,7 @@ There’s *no tradeoff* in power. Instead, we gain the power of simpler composit
241
245
242
246
*Compiling* regular CSS files would be counter-productive to some of our goals. Some of these are listed below.
243
247
244
-
In the future, however, we _might_ be able to take advantage of custom elements / shadow DOM to also support the full CSS syntax once browser support is wide enough.
245
-
248
+
**Please note**: we are very interested in supporting regular CSS, since it's so much easier to write and already familiar. To that end, we're currently exploring the possibility of leveraging Shadow DOM to avoid the entire CSS parsing and mangling step [[#22](https://github.com/zeit/next.js/issues/22)]
246
249
247
250
### Compilation performance
248
251
@@ -256,7 +259,7 @@ It also means fewer dependencies and fewer things for Next to do. Everything is
256
259
257
260
Since every class name is invoked with the `css()` helper, Next.js can intelligently add or remove `<style>` elements that are not being used.
258
261
259
-
This is important for server-side rendering, but also during the lifecycle of the page. Since `Next.js` enables `pushState` transitions that load components dynamically, unnecessary `<style>` elements would bring down performance over time.
262
+
This is important for server-side rendering, but also during the lifecycle of the page. Since Next.js enables `pushState` transitions that load components dynamically, unnecessary `<style>` elements would bring down performance over time.
260
263
261
264
This is a very signifcant benefit over approaches like `require(‘xxxxx.css')`.
262
265
@@ -316,7 +319,7 @@ It’s up to you. `getInitialProps` is an `async` function (or a regular functio
316
319
<details>
317
320
<summary>Why does it load the runtime from a CDN by default?</summary>
318
321
319
-
We intend for `Next.js` to be a great starting point for any website or app, no matter how small.
322
+
We intend for Next.js to be a great starting point for any website or app, no matter how small.
320
323
321
324
If you’re building a very small mostly-content website, you still want to benefit from features like lazy-loading, a component architecture and module bundling.
0 commit comments