PricingBlog

What is the most durable approach to navigation and selected state?

  • alfred_66594-1184030646738374706

    Alfred

    2 years ago

    When establishing a selected state, especially in a navbar, tabs etc, what would be considered the most durable solution? Is it better to:

    1. Trigger the selected state when the URL includes the same path as the navigation component's "path" attribute value?

    2. Create a variable like "currentPath" within the navigation component (e.g., tabs or sidebar) and use it for managing the selected state?

    Additionally, I'm considering organizing all navigation links in a Supabase table, fetching them upon user sign-in, and storing the information in session storage for quick retrieval. Would this approach offer benefits like dynamic, centralized link management, and improved security by limiting returned links based on RLS policies associated with different links?
  • alfred_66594-1184101853819056128

    Alfred

    2 years ago

    What is the most durable approach to navigation and selected state
  • What is the most durable approach to navigation and selected state?
  • erikbeus-1184512699380531230

    Erik Beuschau

    2 years ago

    Hi Alfred.
    Generally, there are a number of benefits when storing your application's state in the url:
    1. It's possible to share a url with others that holds the same state
    2. It's easier for a component to update the state without having to update a state in a parent component
    But depending on your app, there are scenarios where it might be tricky to store the full state in the url (perhaps you don't want to deep link to a dialog being open with some input in it)

    What kind of links do you plan to store in Supabase? And what kind of RLS policies would be associated with the links?