1
00:00:02,000 --> 00:00:05,000
Now that is it for this module.

2
00:00:05,000 --> 00:00:07,000
You could enhance this application

3
00:00:07,000 --> 00:00:11,000
by handling errors and giving the user more feedback.

4
00:00:11,000 --> 00:00:13,000
But that would all be standard React,

5
00:00:13,000 --> 00:00:17,000
there's nothing authentication specific about that.

6
00:00:17,000 --> 00:00:19,000
It's just standard React

7
00:00:19,000 --> 00:00:22,000
as we used it over and over throughout this course.

8
00:00:22,000 --> 00:00:23,000
In this module,

9
00:00:23,000 --> 00:00:27,000
I wanted to focus on the authentication specific parts,

10
00:00:27,000 --> 00:00:30,000
how you can protect routes and pages,

11
00:00:30,000 --> 00:00:34,000
how you can create users, log users in, log users out,

12
00:00:34,000 --> 00:00:36,000
and check their authentication status.

13
00:00:36,000 --> 00:00:39,000
And that's what we did in this module.

14
00:00:39,000 --> 00:00:42,000
Now there's only one last thing left.

15
00:00:42,000 --> 00:00:43,000
One last to do.

16
00:00:43,000 --> 00:00:46,000
And that's this warning, which we're getting here,

17
00:00:46,000 --> 00:00:50,000
that the NextAuth url environment variable is not set.

18
00:00:50,000 --> 00:00:53,000
We can learn in the official NextAuth Docs

19
00:00:53,000 --> 00:00:55,000
that this is an environment variable

20
00:00:55,000 --> 00:00:58,000
which you should set when deploying for production.

21
00:00:58,000 --> 00:01:02,000
Now, I did show you how you can set environment variables

22
00:01:02,000 --> 00:01:05,000
for development and production

23
00:01:05,000 --> 00:01:08,000
in the deployment course section.

24
00:01:08,000 --> 00:01:10,000
And you can apply what you learned there

25
00:01:10,000 --> 00:01:13,000
to add an environment variable of that name,

26
00:01:13,000 --> 00:01:16,000
and then set it to the domain under which

27
00:01:16,000 --> 00:01:19,000
you're going to host your application in production.

28
00:01:19,000 --> 00:01:21,000
And that's important.

29
00:01:21,000 --> 00:01:23,000
We're only talking about production here.

30
00:01:23,000 --> 00:01:26,000
For development, you don't need to do that.

31
00:01:26,000 --> 00:01:29,000
You can, of course, also inject that value

32
00:01:29,000 --> 00:01:32,000
for this environment variable through your hosting provider.

33
00:01:32,000 --> 00:01:35,000
For example, when using Vercel,

34
00:01:35,000 --> 00:01:39,000
which we used in the deployment section, there you also had

35
00:01:39,000 --> 00:01:42,000
environment variables part in your dashboard

36
00:01:42,000 --> 00:01:45,000
where you could set environment variables and their values.

37
00:01:45,000 --> 00:01:49,000
And there you could also set this environment variable

38
00:01:49,000 --> 00:01:50,000
to your actual domain,

39
00:01:50,000 --> 00:01:54,000
your actual url that leads to your website.

40
00:01:55,000 --> 00:01:57,000
So that is something you want to add

41
00:01:57,000 --> 00:02:01,000
when deploying your application that uses authentication.

42
00:02:01,000 --> 00:02:03,000
But with that, we're done,

43
00:02:03,000 --> 00:02:07,000
and you now learn how authentication works with Next.js,

44
00:02:07,000 --> 00:02:09,000
and how it helps you with authentication.

45
00:02:09,000 --> 00:02:12,000
And how you can manage users, creating users,

46
00:02:12,000 --> 00:02:15,000
logging users in, protecting pages and routes,

47
00:02:15,000 --> 00:02:19,000
changing the UI when users are logging in and logging out,

48
00:02:19,000 --> 00:02:22,000
and how you can also protect your API routes.

49
00:02:23,000 --> 00:02:27,000
Now it is worth noting that there are more providers

50
00:02:27,000 --> 00:02:30,000
than the Credentials provider we used.

51
00:02:30,000 --> 00:02:33,000
This is the provider where you manage your own users

52
00:02:33,000 --> 00:02:38,000
with email, password, or whatever your credentials are.

53
00:02:38,000 --> 00:02:40,000
You can also use a third party provider

54
00:02:40,000 --> 00:02:45,000
like Apple or Amazon or GitHub or Facebook.

55
00:02:46,000 --> 00:02:48,000
All of that is possible as well.

56
00:02:48,000 --> 00:02:50,000
You can bring those providers as well,

57
00:02:50,000 --> 00:02:52,000
and if you want to add

58
00:02:52,000 --> 00:02:55,000
this kind of authentication to your application,

59
00:02:55,000 --> 00:02:57,000
simply check out the NextAuth Docs

60
00:02:57,000 --> 00:03:00,000
for that provider you want to use.

61
00:03:00,000 --> 00:03:01,000
And you then learn

62
00:03:01,000 --> 00:03:05,000
how you can add that provider to your application.

63
00:03:05,000 --> 00:03:10,000
And providers in this NextAuth file which you always need,

64
00:03:10,000 --> 00:03:11,000
providers is an array,

65
00:03:11,000 --> 00:03:16,000
so you can always add multiple providers to your application

66
00:03:16,000 --> 00:03:17,000
so that you can offer

67
00:03:17,000 --> 00:03:21,000
multiple log in alternatives to your users.

68
00:03:21,000 --> 00:03:24,000
So NextAuth is very powerful and flexible,

69
00:03:24,000 --> 00:03:27,000
and in this module, you'll learn how you can use it.

