We've now handled our failure case around signing up.
So now we're going to take care of our success case.
So the first thing we want to do is take that Jason web token that we get back from API and store it
on our device.
Remember the Jason web token is essentially a string of characters that will prove to our API that we
are signed in.
We're gonna take that token independent to every request that we make to our API.
After a user is authenticated that API is then going to trust our token and understand that we're the
same person who just logged in a couple of minutes ago.
The reason that we're going to store this on the device is that anytime a user restarts our application
by closing it or turning off their phone and opening it back up anytime that happens all the state inside
of application gets completely wiped away.
So that's all the state inside of our different components and all the state inside of our context as
well.
So rather than making our user log back in every single time that the application gets restarted we're
going to instead store that Jason web token on some long term storage on the device.
This information will be persisted across restarts.
So any time our application gets restarted we can check in local storage or the storage idea and see
if we have a token inside there.
If we have a token we will then assume that we are still logged in.
So let's understand how we're going to work with storage on the device.
So to work with storage we're going to use a little module called async storage async storage has a
couple of different methods tied to it for storing some pieces of information.
So I won't even read off the names these methods because I bet you can guess what each of them does
now async storage is not really for storing say images or video or music or stuff like that.
Instead it's much more about storing not small snippets of information like maybe a Jason object or
something like that.
So it's really perfect for our particular use case here.
Everything we store inside of async storage will be persisted across restarts of our application.
Now there is one downside to async storage.
One quick little gotcha here.
So the time that I am making this video async storage is a part of the react native standard library
but it's going to soon be deprecated.
So that means that at some point time the async storage module that is currently a part of React Native
is going to be removed from the standard library and it's going to instead be a part of a separate module
called React Native async storage that we have to install as a separate library.
However this separate library is not yet compatible with Expo which is what we are using inside of our
application.
So our work around for right now is to continue to use the version of async storage that is included
with the react native standard library even though it is being deprecated then at some point time probably
by the time you watch this video whenever react native async storage is compatible with Expo I'm going
to put up a note after this video until you hey use this other module now instead.
Now this might sound like a real big pain but trust me it's really not a big deal at all.
I've got the documentation for react native async storage so here's the separate new module that we
would ideally be using right here.
So going to take a look down here at the read me a really quick to react native async storage.
Again this is the new version that ideally we would use but is not yet compatible with expo.
So under this section that says usage you'll see that to store data we're supposed to call async storage
dot set item and to read information we call async storage dot get item.
These are the exact same methods as what we use today with the deprecated version of async storage is
the same exact stuff.
So even though you're going to eventually be using a different library it's still the exact same API
same interaction.
Absolutely nothing is different.
So again at some point time if you see a video after this one or a quick note that says hey use the
separate module all you have to do is follow the directions inside that little text lecture.
If you see it after this one if you don't see any separate lecture after this one or any note just use
the async storage.
That is a part of React Native standard library and that's why I to show you in the following videos
after this one date.
So I apologize for the confusion here but again not yet compatible text vote so it's really just the
best we can do.
So now we understand this little caveat here.
Let's take a quick pause and start making use of async storage in the next video.