cf-style-nextjs
Cloudflare Style Next.js integration
This package provides a simple integration of Cloudflare styles (based on Fela) into Next.js framework.
Usage
$ npm install cf-style-nextjs
Your /pages/_document.js
should look similar to this:
import Document Head Main NextScript from 'next/document';import getInitialProps getStyles from 'cf-style-nextjs'; static getInitialProps = ; { return <html> <Head></Head> <body> <Main /> <NextScript /> </body> </html> ; }
and all your pages should be wrapped by <StyleProvider />
:
import StyleProvider from 'cf-style-nextjs';import Button from 'cf-component-button'; <StyleProvider> <Button ="primary" => Welcome! </Button> </StyleProvider>;
Tips
getInitialProps
accepts arbitrary callback, so you can still hook into
getInitialProps lifecycle.
import Document Head Main NextScript from 'next/document';import getInitialProps getStyles from 'cf-style-nextjs'; const MyInitialThing = req const userAgent = req ? reqheaders'user-agent' : navigatoruserAgent; return userAgent ;; static getInitialProps = ; { return <html> <Head></Head> <body> User Agent: thispropsuserAgent <Main /> <NextScript /> </body> </html> ; }