Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] Initial SSR render support #7599

Open
plevamatus opened this issue Jan 18, 2023 · 8 comments
Open

[data grid] Initial SSR render support #7599

plevamatus opened this issue Jan 18, 2023 · 8 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Server integration Better integration with backends, e.g. data source new feature New feature or request waiting for 👍 Waiting for upvotes

Comments

@plevamatus
Copy link

plevamatus commented Jan 18, 2023

Summary 💡

It seems that data grid is not rendered on server. I didn't find any information whether this feature is implemented or whether you plan to implement ssr support in the future.

Examples 🌈

No response

Motivation 🔦

SSR support could improve performance, especially when using large data sets

Order ID 💳 (optional)

No response

@plevamatus plevamatus added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 18, 2023
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Jan 18, 2023
@cherniavskii
Copy link
Member

Hi @plevamatus
The data grid does not support server-side rendering.
Our virtualization needs to measure the dimensions on mount which is not possible with server-side rendering (there's no "mount").

SSR support could improve performance, especially when using large data sets

In theory, it might be possible to make the data grid work with SSR when the virtualization is disabled.
But I believe the gains will be minimal since virtualization is usually enabled when using large data sets, so it won't address your concern.

Have you encountered any specific performance issues?

@cherniavskii cherniavskii added status: waiting for author Issue with insufficient information support: question Community support but can be turned into an improvement and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 18, 2023
@plevamatus
Copy link
Author

Hi @cherniavskii,
I'm working on project based on nextjs, and recently I was comparing mui data grid without SSR and Material React Table (https://www.material-react-table.com/) with SSR. Both support virtualization but the initial render of Material React Table was obviously faster. It was interesting for me, because once both tables were rendered, mui data grid had better performance.
That is why I think that SSR would help, but I was not able to find any relevant information about this feature.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Jan 19, 2023
@cherniavskii
Copy link
Member

@plevamatus Thanks for the update!

Both support virtualization but the initial render of Material React Table was obviously faster.

Did you render both grids on the same page? By initial render you mean the time from the page load to the first grid render with the data?

@cherniavskii cherniavskii changed the title Data grid SSR support [data grid] SSR support Jan 20, 2023
@cherniavskii cherniavskii added status: waiting for author Issue with insufficient information new feature New feature or request waiting for 👍 Waiting for upvotes and removed status: waiting for author Issue with insufficient information support: question Community support but can be turned into an improvement labels Jan 20, 2023
@cherniavskii
Copy link
Member

One more request for SSR support: #6803 (comment)

@cherniavskii
Copy link
Member

I explored this a bit and created a quick PoC in my fork: cherniavskii#5

@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Jan 27, 2023
@cherniavskii cherniavskii moved this from 🆕 Needs refinement to 🔖 Ready in MUI X Data Grid Jan 31, 2023
@oliviertassinari oliviertassinari added the feature: Server integration Better integration with backends, e.g. data source label Mar 19, 2023
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 19, 2023

SSR support sounds like a great opportunity to improve the UX for the first-page load on dashboards. The data grid is often the primary content on the page end-users open to read but all the JavaScript needs to load first to be able to access the data. This problem is getting worse with Next.js's popularity and React's team push toward the server. Now, end-users also need to wait for the hydration to complete.

For the technical solution, I imagine that we could expose a new prop, e.g. initial VirtualizationDimension that represents the expected area of the grid so that the virtualization should render server side.


It's not directly related, but we could connect this SSR issue, #7583, and #8179 with the RSC (React Server Components): https://twitter.com/devagrawal09/status/1636971320138162176.

@Melihkrkvk
Copy link

Melihkrkvk commented Feb 13, 2024

Hi @cherniavskii, I'm working on project based on nextjs, and recently I was comparing mui data grid without SSR and Material React Table (https://www.material-react-table.com/) with SSR. Both support virtualization but the initial render of Material React Table was obviously faster. It was interesting for me, because once both tables were rendered, mui data grid had better performance. That is why I think that SSR would help, but I was not able to find any relevant information about this feature.

I am using metarial react table with nextjs14. I found a way that table run with ssr. I don't know it is best practice for nextjs or not? I am using that table with searchParams.

//MaterialTable.tsx 
manualPagination = true,
onPaginationChange: (updaterOrValue: any) => {
      (() => {
        const newPaginationValue = updaterOrValue(pagination);
        setPagination(newPaginationValue);
        const params = new URLSearchParams(searchParams.toString());
        params.set('page', newPaginationValue.pageIndex + 1);
        params.set('pageSize', newPaginationValue.pageSize);
        router.push('?' + params);
      })();
    },`
//page.tsx
    `await fetchData(USER_QUERY, {
    take: Number(searchParams.pageSize),
    skip: skip,

@oliviertassinari oliviertassinari changed the title [data grid] SSR support [data grid] Initial SSR render support Feb 14, 2024
@Janpot
Copy link
Member

Janpot commented May 14, 2024

Our virtualization needs to measure the dimensions on mount which is not possible with server-side rendering (there's no "mount").

I'm experiencing this as well. Having a dashboard that displays some cards with graphs, and a data grid. The cards are perfectly able to SSR, but the datagrid shows nothing until mounted. This causes a flicker in some parts of the dashboard. Even if parts of the grid require measurement, I believe it should be possible to render at least the border, toolbar, footer, column header (without individual columns). And as long as it's not mounted, the loading state could be displayed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Server integration Better integration with backends, e.g. data source new feature New feature or request waiting for 👍 Waiting for upvotes
Projects
Status: 🔖 Ready
Development

No branches or pull requests

6 participants