rsnext/examples/with-styled-components-babel
Aleksa Cukovic bcd8de3262
Add *.tsbuildinfo to .gitignore of examples that use typescript (#38005)
I added ` *.tsbuildinfo` to gitignores of examples that use typescript and don't already have it. By use typescript I mean have `tsconfig` somewhere in their directory tree. 

I used the following script to update the files:

```bash
#!/bin/bash

set -eou pipefail

cd examples
examples=`git ls-files . | grep tsconfig | xargs dirname | grep -v "/"`

for example in $examples; do
    if ! grep -q tsbuildinfo $example/.gitignore; then
        gitignore="$example/.gitignore"
        echo $gitignore
        tail -c1 $gitignore | read -r _ || echo >> $gitignore
        echo -e "\n# typescript\n*.tsbuildinfo" >> $gitignore
    fi
done
```
2022-06-26 11:17:44 +00:00
..
pages [examples] Update styled-components with Babel - add types (#36125) 2022-04-27 12:43:06 +00:00
.babelrc [examples] Update styled-components to use SWC (#34770) 2022-03-02 03:43:34 +01:00
.gitignore Add *.tsbuildinfo to .gitignore of examples that use typescript (#38005) 2022-06-26 11:17:44 +00:00
next-env.d.ts [examples] Update styled-components with Babel - add types (#36125) 2022-04-27 12:43:06 +00:00
package.json Fix failing yarn PnP test from missing dependency (#36515) 2022-04-27 17:32:44 +02:00
README.md Update pnpm create next-app for latest pnpm 6 and 7 (#37254) 2022-05-27 21:21:40 +00:00
tsconfig.json [examples] Update styled-components with Babel - add types (#36125) 2022-04-27 12:43:06 +00:00

Example app with styled-components using babel

This example features how you use a different styling solution than 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 styled-components.

For this purpose we are extending the <Document /> and injecting the server side rendered styles into the <head>, and also adding the babel-plugin-styled-components (which is required for server side rendering). Additionally we set up a global theme for styled-components using NextJS custom <App> component.

Preview

Preview the example live on StackBlitz:

Open in StackBlitz

Deploy your own

Deploy the example using Vercel:

Deploy with Vercel

How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example with-styled-components-babel with-styled-components-babel-app
# or
yarn create next-app --example with-styled-components-babel with-styled-components-babel-app
# or
pnpm create next-app --example with-styled-components-babel with-styled-components-babel-app

Deploy it to the cloud with Vercel (Documentation).