Skip to content

What's the prescribed approach for performing a data lookup and redirect on the server side using cargo-leptos? #2037

Answered by gbj
saikatdas0790 asked this question in Q&A
Discussion options

You must be logged in to vote
  1. encapsulate that redirection logic in a server function
  2. use create_blocking_resource to call that server function
  3. read that resource in a Suspense

This may seem overly complicated but the benefit is that it behaves in exactly the same way on the client or the server: i.e., if someone initially loads /, it will serve them the redirect from the server. If they then navigate back to / on the client, it will call the server to get a new redirect URL and go there from the client.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@gbj
Comment options

gbj Nov 20, 2023
Maintainer

@saikatdas0790
Comment options

@saikatdas0790
Comment options

@gbj
Comment options

gbj Nov 20, 2023
Maintainer

Answer selected by saikatdas0790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants