Skip to content

Commit becae90

Browse files
committed
Merge branch 'master' of https://github.com/zeit/next.js
2 parents 81612f8 + 1952a47 commit becae90

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

Readme.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# next.js
22

3-
`Next.js` is a minimalistic framework for server-rendered React applications.
3+
Next.js is a minimalistic framework for server-rendered React applications.
44

55
## How to use
66

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.
814

915
Populate `./pages/index.js` inside your project:
1016

@@ -83,7 +89,7 @@ export default () => (
8389
)
8490
```
8591

86-
### Lifecycle components
92+
### Component lifecycle
8793

8894
When you need state, lifecycle hooks or **initial data population** you can export a `React.Component`:
8995

@@ -219,16 +225,14 @@ Yes and No.
219225
Yes in that both make your life easier.
220226

221227
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
224230

225231
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`)
230234

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!
232236

233237
</details>
234238

@@ -241,8 +245,7 @@ There’s *no tradeoff* in power. Instead, we gain the power of simpler composit
241245

242246
*Compiling* regular CSS files would be counter-productive to some of our goals. Some of these are listed below.
243247

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)]
246249

247250
### Compilation performance
248251

@@ -256,7 +259,7 @@ It also means fewer dependencies and fewer things for Next to do. Everything is
256259

257260
Since every class name is invoked with the `css()` helper, Next.js can intelligently add or remove `<style>` elements that are not being used.
258261

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.
260263

261264
This is a very signifcant benefit over approaches like `require(‘xxxxx.css')`.
262265

@@ -316,7 +319,7 @@ It’s up to you. `getInitialProps` is an `async` function (or a regular functio
316319
<details>
317320
<summary>Why does it load the runtime from a CDN by default?</summary>
318321

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.
320323

321324
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.
322325

lib/css.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
module.exports = require('glamor')
1+
const css = require('glamor')
2+
3+
/**
4+
* Expose style as default and the whole object as properties
5+
* so it can be used as follows:
6+
*
7+
* import css, { merge } from 'next/css'
8+
* css({ color: 'red' })
9+
* merge({ color: 'green' })
10+
* css.merge({ color: 'blue' })
11+
*/
12+
13+
css.default = css.style
14+
Object.keys(css).forEach(key => {
15+
if (key !== 'default') {
16+
css.default[key] = css[key]
17+
}
18+
})
19+
20+
module.exports = css

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@zeit/next",
2+
"name": "next",
33
"version": "0.0.0",
44
"description": "",
55
"main": "./dist/lib/index.js",

0 commit comments

Comments
 (0)