diff --git a/README.md b/README.md
index b2f2072c..ad83d030 100644
--- a/README.md
+++ b/README.md
@@ -93,6 +93,14 @@ export default () => (
#### CSS-in-JS
+
+ Examples
+
+
+
It's possible to use any existing CSS-in-JS solution. The simplest one is inline styles:
```jsx
diff --git a/examples/with-styletron/README.md b/examples/with-styletron/README.md
new file mode 100644
index 00000000..6accfc72
--- /dev/null
+++ b/examples/with-styletron/README.md
@@ -0,0 +1,30 @@
+
+# Example app with styletron
+
+## How to use
+
+Download the example (or clone the repo)[https://github.com/zeit/next.js.git]:
+
+```bash
+curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-styletron
+cd with-styletron
+```
+
+Install it and run:
+
+```bash
+npm install
+npm run dev
+```
+
+Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
+
+```bash
+now
+```
+
+## The idea behind the example
+
+This example features how yo use a different styling solution than [styled-jsx](https://github.com/zeit/styled-jsx) that also supports universal styles. That means we can serve the required styles for the first render within the HTML and then load the rest in the client. In this case we are using [styletron](https://github.com/rtsao/styletron).
+
+For this purpose we are extending the `` and injecting the server side rendered styles into the ``.
diff --git a/examples/with-styletron/layout.js b/examples/with-styletron/layout.js
new file mode 100644
index 00000000..9fe974aa
--- /dev/null
+++ b/examples/with-styletron/layout.js
@@ -0,0 +1,8 @@
+import { StyletronProvider } from 'styletron-react'
+import getStyletron from './styletron'
+
+export default ({ children }) => (
+
+ {children}
+
+)
diff --git a/examples/with-styletron/next.config.js b/examples/with-styletron/next.config.js
new file mode 100644
index 00000000..cd8910d8
--- /dev/null
+++ b/examples/with-styletron/next.config.js
@@ -0,0 +1,7 @@
+module.exports = {
+ webpack: function (config) {
+ config.externals = config.externals || {}
+ config.externals['styletron-server'] = 'styletron-server'
+ return config
+ }
+}
diff --git a/examples/with-styletron/package.json b/examples/with-styletron/package.json
new file mode 100644
index 00000000..4853f9f2
--- /dev/null
+++ b/examples/with-styletron/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "with-styletron",
+ "version": "1.0.0",
+ "scripts": {
+ "dev": "next",
+ "build": "next build",
+ "start": "next start"
+ },
+ "dependencies": {
+ "next": "^2.0.0-beta",
+ "styletron-client": "^2.2.0",
+ "styletron-react": "^2.2.1",
+ "styletron-server": "^2.2.0"
+ }
+}
diff --git a/examples/with-styletron/pages/_document.js b/examples/with-styletron/pages/_document.js
new file mode 100644
index 00000000..ebc33b4e
--- /dev/null
+++ b/examples/with-styletron/pages/_document.js
@@ -0,0 +1,26 @@
+import Document, { Head, Main, NextScript } from 'next/document'
+import { flush } from '../styletron'
+
+export default class MyDocument extends Document {
+ static getInitialProps ({ renderPage }) {
+ const page = renderPage()
+ const styletron = flush()
+ const css = styletron ? styletron.getCss() : null
+ return { ...page, css }
+ }
+
+ render () {
+ return (
+
+
+ My page
+
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/examples/with-styletron/pages/index.js b/examples/with-styletron/pages/index.js
new file mode 100644
index 00000000..97de34ee
--- /dev/null
+++ b/examples/with-styletron/pages/index.js
@@ -0,0 +1,13 @@
+import { styled } from 'styletron-react'
+import Page from '../layout'
+
+const Title = styled('div', {
+ color: 'red',
+ fontSize: '50px'
+})
+
+export default () => (
+
+ My page
+
+)
diff --git a/examples/with-styletron/styletron.js b/examples/with-styletron/styletron.js
new file mode 100644
index 00000000..017f7c68
--- /dev/null
+++ b/examples/with-styletron/styletron.js
@@ -0,0 +1,23 @@
+
+const isServer = typeof window === 'undefined'
+
+let styletron
+
+export default function getStyletron () {
+ if (isServer) {
+ const Styletron = require('styletron-server')
+ styletron = new Styletron()
+ } else if (!styletron) {
+ const Styletron = require('styletron-client')
+ const styleElements = document.getElementsByClassName('_styletron_hydrate_')
+ styletron = new Styletron(styleElements)
+ }
+
+ return styletron
+}
+
+export function flush () {
+ const _styletron = styletron
+ styletron = null
+ return _styletron
+}