Skip to content

Persist state from Static Server Rendering (SSR) to Interactive islands #60253

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

Closed
1 task done
Johnlockk opened this issue Feb 7, 2025 · 3 comments
Closed
1 task done
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@Johnlockk
Copy link

Johnlockk commented Feb 7, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Hello,

i've searched for a solution but i didn't understand if anything has been implemented yet.
I have a Blazor Web App composed of two SSR Components, login and logout (to handle Cookie authentication) ,while the rest of components are all on InteractiveServer render mode.
During the login procedure i'm receiving an access token from a secured endpoint to be used for the subsequent API calls on Interactive components. Is there any way to persist the token or any other user data while switching from SSR to InteractiveServer?

Similar to #47796 and #50741, not sure if any action has been taken.

Thank you

Describe the solution you'd like

It would be great to have a transparent and flexible mechanism to persiste state from SSR to Interactive islands

Additional context

No response

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Feb 7, 2025
@javiercn
Copy link
Member

@Johnlockk thanks for contacting us.

This is already possible with PersistentComponentState. See https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerender?view=aspnetcore-9.0#persist-prerendered-state

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels Feb 10, 2025
@Johnlockk
Copy link
Author

@javiercn Thank you...it seems that navigating away from the SSR component is not storing the state for the next Interactive component, not sure if this is by design. ApplicationState seems to be reinitialized and the TryTakeFromJson call returns a null value. Is PersistentComponentState only useful to maintain the state in case of prerendering? Thanks

Copy link
Contributor

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants