55 lines
2.3 KiB
Markdown
55 lines
2.3 KiB
Markdown
|
|
# Material UI - Next.js Pages Router example in TypeScript
|
|||
|
|
|
|||
|
|
## How to use
|
|||
|
|
|
|||
|
|
Download the example [or clone the repo](https://github.com/mui/material-ui):
|
|||
|
|
|
|||
|
|
<!-- #target-branch-reference -->
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-nextjs-pages-router-ts
|
|||
|
|
cd material-ui-nextjs-pages-router-ts
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Install it and run:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
npm install
|
|||
|
|
npm run dev
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
or:
|
|||
|
|
|
|||
|
|
<!-- #target-branch-reference -->
|
|||
|
|
|
|||
|
|
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-nextjs-pages-router-ts)
|
|||
|
|
|
|||
|
|
[](https://codesandbox.io/p/sandbox/github/mui/material-ui/tree/master/examples/material-ui-nextjs-pages-router-ts)
|
|||
|
|
|
|||
|
|
## The idea behind the example
|
|||
|
|
|
|||
|
|
**Note:** This example is set up to use the Next.js Pages Router.
|
|||
|
|
As of Next.js 13.4, the newer App Router pattern is stable.
|
|||
|
|
We recommend starting new projects with the [Material UI with Next.js (App Router) example](https://github.com/mui/material-ui/tree/master/examples/material-ui-nextjs-ts) unless you need (or prefer) the Pages Router.
|
|||
|
|
|
|||
|
|
<!-- #host-reference -->
|
|||
|
|
|
|||
|
|
The project uses [Next.js](https://github.com/vercel/next.js), which is a framework for server-rendered React apps.
|
|||
|
|
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI.
|
|||
|
|
If you prefer, you can [use styled-components instead](https://mui.com/material-ui/integrations/interoperability/#styled-components).
|
|||
|
|
|
|||
|
|
## The link component
|
|||
|
|
|
|||
|
|
<!-- #target-branch-reference -->
|
|||
|
|
<!-- #host-reference -->
|
|||
|
|
|
|||
|
|
The [example folder](https://github.com/mui/material-ui/tree/HEAD/examples/material-ui-nextjs-pages-router-ts) provides an adapter for the use of [Next.js's Link component](https://nextjs.org/docs/pages/api-reference/components/link) with Material UI.
|
|||
|
|
More information [in the documentation](https://mui.com/material-ui/integrations/routing/#next-js-pages-router).
|
|||
|
|
|
|||
|
|
## What's next?
|
|||
|
|
|
|||
|
|
<!-- #host-reference -->
|
|||
|
|
|
|||
|
|
You now have a working example project.
|
|||
|
|
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
|