sharing data between routes
Answered
JJSenpai posted this in #help-forum
JJSenpaiOP
I have a list of data that user selects from a route, and I need the same in other route as well. How do I share data between routes. Will using a context make the components wrapped in it client side?
Answered by joulev
Using a context will not make the components inside it client components, though you can only consume the data in client components.
To share data to a server component, you must use data sources that server components can access. Namely: URL (pathname/query), cookies, server-side data sources such as databases.
To share data to a server component, you must use data sources that server components can access. Namely: URL (pathname/query), cookies, server-side data sources such as databases.
3 Replies
@JJSenpai I have a list of data that user selects from a route, and I need the same in other route as well. How do I share data between routes. Will using a context make the components wrapped in it client side?
Using a context will not make the components inside it client components, though you can only consume the data in client components.
To share data to a server component, you must use data sources that server components can access. Namely: URL (pathname/query), cookies, server-side data sources such as databases.
To share data to a server component, you must use data sources that server components can access. Namely: URL (pathname/query), cookies, server-side data sources such as databases.
Answer
JJSenpaiOP
@joulev Thanks for the help.
Also is there a way I can analyze the time taken by server to render components?
Also is there a way I can analyze the time taken by server to render components?
@JJSenpai <@484037068239142956> Thanks for the help.
Also is there a way I can analyze the time taken by server to render components?
Other than classic methods like console.time(), no I don’t know of any methods for that