How to: Add a search bar to NavigationView in SwiftUI

A fast way to add a search bar to your SwiftUI app with fuzzy search and NavigationView. (Bonus: becomeFirstResponder)

NavigationView SearchBar Image
NavigationView SearchBar

In the latest version of iOS 15 sdk, you can now use the .searchable(:) modifier to achieve search behavior. Only continue with this article…