Data fetching strategy with Next.js for a dashboard-like app
Hi
I hope this is the right place for a discussion like this
In the past, I was mainly developing mostly static websites with a few interactive elements. Now I'm planning to do a personal project with a more app-like behaviour and was wondering what the best practice is regarding data fetching with Next.js, especially with the T3 Stack.
Some challenges that come to mind:
-
- Different users may want to display different data on the home page, so I need to have a way to prepare that view for each user seperately.
- Some data may come from a 3rd party API that won't be as quick to respond as the main data source.
- Loading states and navigation should be smooth.
What I thought could work:
- Use client side queries for all the data that is user-specific.
- Use
What I ask myself:
- Is it worth to make this distinction, or should I just go with client-side fetching all the way?
- Also, what about the future of the stack with Next.js'
I hope this is the right place for a discussion like this
In the past, I was mainly developing mostly static websites with a few interactive elements. Now I'm planning to do a personal project with a more app-like behaviour and was wondering what the best practice is regarding data fetching with Next.js, especially with the T3 Stack.
Some challenges that come to mind:
-
getServerSideProps is probably preferred over getInitialProps, since caching is only so useful if you want to analyze live-data as a user.- Different users may want to display different data on the home page, so I need to have a way to prepare that view for each user seperately.
- Some data may come from a 3rd party API that won't be as quick to respond as the main data source.
- Loading states and navigation should be smooth.
What I thought could work:
- Use client side queries for all the data that is user-specific.
- Use
getServerSideProps to fetch all the non-user specific stuff on a page. E.g. navigation bar state, form views (where you can edit entities) etc.What I ask myself:
- Is it worth to make this distinction, or should I just go with client-side fetching all the way?
- Also, what about the future of the stack with Next.js'
app folder and server components. Will the transition be easier if I fetch everything client side?