Summary
In this chapter, you learned about session and state management in Remix. First, you learned how to use URL search parameters to persist application state using Remix’s Form
component and the useSearchParams
hook. The URL is often all we need to handle application state.
You also practiced using useSubmit
to submit a form programmatically and learned more about Remix’s different mutation utilities. We concluded that we use the Form
component and the useSubmit
hook for the primary actions on the page; useFetcher
is used to support concurrent submissions with isolated submission states.
Next, you learned that cookies are part of the HTTP protocol and can be used to persist state across page transitions. Cookies are a great tool for session management. Remix provides helper functions for working with cookies and sessions. Remix’s session primitives allow us to manage sessions using different strategies, such as storing session data in memory, files,...