Skip to content

Commit

Permalink
[docs] Add next.js styled-component guide and update links to example (
Browse files Browse the repository at this point in the history
  • Loading branch information
Jareechang authored Oct 27, 2021
1 parent f9d7beb commit c3f7491
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion docs/src/pages/guides/styled-engine/styled-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,40 @@ If you are using TypeScript, you will need to also update the TSConfig.
}
```

### Next.js

**next.config.js**

```diff
+const withTM = require('next-transpile-modules')([
+ '@mui/material',
+ '@mui/system',
+ '@mui/icons-material', // If @mui/icons-material is being used
+]);

+module.exports = withTM({
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
+ '@mui/styled-engine': '@mui/styled-engine-sc',
};
return config;
}
+});
```

### Ready-to-use examples

If you are using create-react-app, there is a ready-to-use template in the example projects.
You can use the [create-react-app-with-styled-components example](https://github.com/mui-org/material-ui/tree/next/examples/create-react-app-with-styled-components), or its [TypeScript equivalent](https://github.com/mui-org/material-ui/tree/next/examples/create-react-app-with-styled-components-typescript).

You can use these `styled-component` examples as a reference:

<!-- #default-branch-switch -->

- [create-react-app](https://github.com/mui-org/material-ui/tree/master/examples/create-react-app-with-styled-components)
- [create-react-app with TypeScript](https://github.com/mui-org/material-ui/tree/master/examples/create-react-app-with-styled-components-typescript)
- [Next.js](https://github.com/mui-org/material-ui/tree/master/examples/nextjs-with-styled-components-typescript)
- [and many others](https://github.com/mui-org/material-ui/tree/master/examples)

> **Note**: `@emotion/react`, `@emotion/styled`, and `styled-components` are optional peer dependencies of `@mui/material`, so you need to install them yourself. See the [Installation guide](/getting-started/installation/) for more info.
Expand Down

0 comments on commit c3f7491

Please sign in to comment.