How to store login state in SwiftUI?

Hey everyone,
What’s the best way to keep a user logged in using SwiftUI? Just looking for a simple and safe method. Appreciate any pointers!

You can use @AppStorage to keep track of the user’s login status:

@AppStorage("LoggedIn") var loggedIn = false

When you determine that the user has met the conditions to be logged in, just set loggedIn to true. Then you can check that variable whenever you need to.