Skip to content

Performance of navigation drops with increasing complexity #3965

@flodaniel

Description

@flodaniel

Which project does this relate to?

Router

Describe the bug

When trying to find a way to update a search param without calling navigate, performance of navigate decreases with increasing complexity of various components.

So far I failed to narrow it down to a single issue but what seems to be impacting the performance are:

  • Number of routes
  • size of objects in context (e.g. having the QueryClient in the context)
  • usage of hooks such as useMatches() which re-runs on each navigation
  • Complexity of UI (number and how much has to be re-rendered)

The issue is hard to reproduce but the attached example shows it a little bit.

Discord discussion: https://discord.com/channels/719702312431386674/1359211140923789502

Your Example Website or App

https://github.com/flodaniel/tsr-navigate-performance

Steps to Reproduce the Bug or Issue

  1. Run app
  2. observe performance of a plain html input field vs a input field that manages its state through a search param, which has to be updated with navigate

Expected behavior

As a developer I would expect that managing state in the search bar comes with close to 0 impact on overall performance. We migrated from RR6 where we used nuqs where this was possible.

Screenshots or Videos

Platform

  • OS: macOs
  • Browser: Brave
  • Version: 1.115.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions