Skip to content

Commit

Permalink
[docs] Remove flag from installation page
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 9, 2023
1 parent c8568ae commit 5be2780
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<p class="description">Learn how to use Base UI with the Next.js App Router.</p>

:::info
## Example

Starting fresh on a new App Router-based project?

Jump right into the code with [this example: Base UI - Next.js App Router with Tailwind CSS example in TypeScript](https://github.com/mui/material-ui/tree/master/examples/base-ui-nextjs-tailwind-ts).
:::
Jump right into the code with [this example: Base UI - Next.js App Router with Tailwind CSS in TypeScript](https://github.com/mui/material-ui/tree/master/examples/base-ui-nextjs-tailwind-ts).

## Next.js and React Server Components

The Next.js App Router implements React Server Components, [an upcoming feature for React](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md).

To support the App Router, currently all components and hooks from Base UI and other MUI libraries are exported with the `"use client"` directive.
To support the App Router, the components and hooks from Base UI that need access to browser APIs are exported with the `"use client"` directive.

:::warning
React Server Components should not be conflated with the concept of server-side rendering (SSR).
Expand All @@ -36,7 +36,6 @@ module.exports = {
content: [
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}'

// or if not using the `src` directory:
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<p class="description">Learn how to use Joy UI with the Next.js App Router.</p>

:::info
## Example

Starting fresh on a new App Router-based project?

Jump right into the code with [this example: Joy UI - Next.js App Router with TypeScript](https://github.com/mui/material-ui/tree/master/examples/joy-ui-nextjs-ts).
:::

## Next.js and React Server Components

The Next.js App Router implements React Server Components, [an upcoming feature for React](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md).

To support the App Router, currently all components and hooks from Joy UI and other MUI libraries are exported with the `"use client"` directive.
To support the App Router, the components and hooks from Joy UI that need access to browser APIs are exported with the `"use client"` directive.

:::warning
React Server Components should not be conflated with the concept of server-side rendering (SSR).
Expand Down Expand Up @@ -104,37 +104,40 @@ export default function RootLayout(props) {
}
```

## Function props
## Props serialization

Props passed from server components-for example `page.js` or other routing files-must be [serializable](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#passing-props-from-server-to-client-components-serialization).

:::success
This works without any additional directives:

```jsx
```tsx
// app/page.tsx
import Sheet from '@mui/joy/Sheet';
import Typography from '@mui/joy/Typography';

export default function Page() {
return (
<Sheet variant="outlined">
<Sheet>
<Typography fontSize="sm">Hello World</Typography>
</Sheet>
);
}
```

:::

:::error
This code snippet _doesn't work_, because the Button's click handler is **non-serializable**:
This _doesn't work_ because the Button's click handler is **non-serializable**:

```tsx
// page.tsx
// app/page.tsx
import Button from '@mui/joy/Button';
import Sheet from '@mui/joy/Sheet';

export default function Page() {
return (
<Sheet variant="outlined">
<Sheet>
{/* Next.js won't render this button without 'use-client' */}
<Button
variant="outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

<p class="description">Install Material UI, the world's most popular React UI framework.</p>

:::success
We are currently working on supporting React Server Components in Material UI.

All components and hooks are exported as [Client Components](https://nextjs.org/docs/getting-started/react-essentials#client-components) with the `"use client"` directive.
If you're using Next.js 13.4 or later, check out the [Next.js App Router guide](/material-ui/guides/next-js-app-router/).

:::

## Default installation

Run one of the following commands to add Material UI to your project:
Expand Down
35 changes: 16 additions & 19 deletions docs/data/material/guides/next-js-app-router/next-js-app-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

<p class="description">Learn how to use Material UI with the Next.js App Router.</p>

:::info
## Example

Starting fresh on a new App Router-based project?

Jump right into the code with [this example: Material UI - Next.js App Router example in TypeScript](https://github.com/mui/material-ui/tree/master/examples/material-ui-nextjs-ts).
:::
Jump right into the code with [this example: Material UI - Next.js App Router in TypeScript](https://github.com/mui/material-ui/tree/master/examples/material-ui-nextjs-ts).

## Next.js and React Server Components

The Next.js App Router implements React Server Components, [an upcoming feature for React](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md).

To support the App Router, currently all components and hooks from MUI libraries (Material UI, Joy UI, Base UI etc.) are exported with the `"use client"` directive.
To support the App Router, the components and hooks from Material UI that need access to browser APIs are exported with the `"use client"` directive.

:::warning
React Server Components should not be conflated with the concept of server-side rendering (SSR).
React Server Components is not the same concept as server-side rendering (SSR).
So-called Client Components are still server-rendered to HTML.

For more details, see [this explanation](https://github.com/reactwg/server-components/discussions/4) of Client Components and SSR from the React Working Group.
Expand Down Expand Up @@ -176,43 +176,40 @@ Currently, `prepend` does not work reliably with the App Router, but you can wor
});
```

## Function props
## Props serialization

Props passed from Server Components—for example `page.js` or other routing files—must be [serializable](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#passing-props-from-server-to-client-components-serialization).

:::success
This works without any additional directives:

```jsx
```tsx
// app/page.tsx
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';

export default function Page() {
return (
<Container maxWidth="lg">
<Box>
<Card raised>
<Typography variant="h2">Hello World</Typography>
</Card>
</Box>
<Container>
<Typography variant="h2">Hello World</Typography>
</Container>
);
}
```

:::

:::error
This code snippet _doesn't work_, because the Button's click handler is **non-serializable**:
This _doesn't work_ because the Button's click handler is **non-serializable**:

```tsx
// page.tsx
import Button from '@mui/material/Button';
// app/page.tsx
import Container from '@mui/material/Container';
import Button from '@mui/material/Button';

export default function Page() {
return (
<Container maxWidth="lg">
<Container>
{/* Next.js won't render this button without 'use-client' */}
<Button
variant="text"
Expand Down

0 comments on commit 5be2780

Please sign in to comment.