Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,280 --> 00:00:06,720
now another benefit of next.js is
2
00:00:04,080 --> 00:00:09,599
serverless functions
3
00:00:06,720 --> 00:00:10,880
remember when i call next.jsp fullstack
4
00:00:09,599 --> 00:00:12,480
framework
5
00:00:10,880 --> 00:00:14,960
this is why
6
00:00:12,480 --> 00:00:17,119
you can essentially run your node.js
7
00:00:14,960 --> 00:00:18,400
code in the same codebase as your
8
00:00:17,119 --> 00:00:20,880
reaccode
9
00:00:18,400 --> 00:00:21,920
and it all lives inside the pages
10
00:00:20,880 --> 00:00:24,640
directory
11
00:00:21,920 --> 00:00:26,560
now anything inside the api folder you
12
00:00:24,640 --> 00:00:29,199
will automatically
13
00:00:26,560 --> 00:00:31,119
route to it right it automatically a
14
00:00:29,199 --> 00:00:33,600
route is created for that because of the
15
00:00:31,119 --> 00:00:36,880
next year's file system based routing
16
00:00:33,600 --> 00:00:39,440
right but also anything under the api
17
00:00:36,880 --> 00:00:42,879
folder also has a node server configured
18
00:00:39,440 --> 00:00:44,719
already and it all comes out of the box
19
00:00:42,879 --> 00:00:47,200
what's really cool is that you can do
20
00:00:44,719 --> 00:00:49,200
all of this without any configuration
21
00:00:47,200 --> 00:00:51,280
and your front end can easily talk to
22
00:00:49,200 --> 00:00:54,239
your backend that is the serverless
23
00:00:51,280 --> 00:00:57,520
function so in an example here hello is
24
00:00:54,239 --> 00:01:01,039
actually a serverless function
25
00:00:57,520 --> 00:01:03,199
now what exactly is the advantage here
26
00:01:01,039 --> 00:01:05,680
why do we want to make sure that we want
27
00:01:03,199 --> 00:01:07,600
our front-end to talk to our back-end
28
00:01:05,680 --> 00:01:09,920
well let's take a look
29
00:01:07,600 --> 00:01:13,439
if you're trying to go ahead and call a
30
00:01:09,920 --> 00:01:15,439
foursquare api or an airtable api
31
00:01:13,439 --> 00:01:18,240
or any other api
32
00:01:15,439 --> 00:01:20,240
that has specific secret credentials
33
00:01:18,240 --> 00:01:21,439
that we don't want to share with anyone
34
00:01:20,240 --> 00:01:22,560
right
35
00:01:21,439 --> 00:01:25,119
you don't want to store those
36
00:01:22,560 --> 00:01:27,119
credentials on your client because any
37
00:01:25,119 --> 00:01:29,360
malicious user can go ahead and access
38
00:01:27,119 --> 00:01:32,479
it but instead you want to store those
39
00:01:29,360 --> 00:01:34,880
credentials on the server
40
00:01:32,479 --> 00:01:36,640
that api key should be on the server
41
00:01:34,880 --> 00:01:37,840
that you should be hiding from your end
42
00:01:36,640 --> 00:01:39,680
users
43
00:01:37,840 --> 00:01:41,280
and this is possible because of
44
00:01:39,680 --> 00:01:43,119
serverless functions
45
00:01:41,280 --> 00:01:45,520
the front end can easily talk to your
46
00:01:43,119 --> 00:01:48,960
backend and backend will be the place
47
00:01:45,520 --> 00:01:51,280
where you will call these specific apis
48
00:01:48,960 --> 00:01:53,280
but if you're wondering wait hold on a
49
00:01:51,280 --> 00:01:55,759
second now that we know all the
50
00:01:53,280 --> 00:01:57,600
capabilities of serverless function what
51
00:01:55,759 --> 00:01:59,920
exactly are they
52
00:01:57,600 --> 00:02:01,200
what does what do we mean by serverless
53
00:01:59,920 --> 00:02:03,360
functions
54
00:02:01,200 --> 00:02:04,479
well let's take a look at the diagram
55
00:02:03,360 --> 00:02:06,159
here
56
00:02:04,479 --> 00:02:08,560
as we make a request to a serverless
57
00:02:06,159 --> 00:02:10,720
function called as hello essentially
58
00:02:08,560 --> 00:02:12,720
what's going to happen is
59
00:02:10,720 --> 00:02:15,120
it is going to go ahead and spin up a
60
00:02:12,720 --> 00:02:18,239
new server just to make sure that it
61
00:02:15,120 --> 00:02:20,239
fulfills that specific request and after
62
00:02:18,239 --> 00:02:21,440
no activity it is going to go ahead and
63
00:02:20,239 --> 00:02:22,160
shut down
64
00:02:21,440 --> 00:02:25,520
so
65
00:02:22,160 --> 00:02:27,760
the minute we call slash api hello it is
66
00:02:25,520 --> 00:02:30,239
going to wake up the server start a
67
00:02:27,760 --> 00:02:33,680
brand new node server it is going to
68
00:02:30,239 --> 00:02:35,680
execute the code inside the hello api
69
00:02:33,680 --> 00:02:38,239
and then go ahead and
70
00:02:35,680 --> 00:02:41,280
execute it successfully
71
00:02:38,239 --> 00:02:43,840
and then shut down the server
72
00:02:41,280 --> 00:02:46,160
so this is why it is called a serverless
73
00:02:43,840 --> 00:02:48,480
function you only need the server to
74
00:02:46,160 --> 00:02:50,319
perform that specific task and if there
75
00:02:48,480 --> 00:02:52,480
is no activity it is going to go ahead
76
00:02:50,319 --> 00:02:54,959
and shut it down
77
00:02:52,480 --> 00:02:56,080
so this is the power of serverless
78
00:02:54,959 --> 00:02:58,640
functions
79
00:02:56,080 --> 00:03:01,200
and all of this is already configured in
80
00:02:58,640 --> 00:03:03,760
xjs you don't need to do any additional
81
00:03:01,200 --> 00:03:06,000
setup for it all we need to do is go
82
00:03:03,760 --> 00:03:07,599
ahead and create a new file under the
83
00:03:06,000 --> 00:03:10,239
api folder
84
00:03:07,599 --> 00:03:11,680
serverless functions are really powerful
85
00:03:10,239 --> 00:03:13,920
because you don't need to keep your
86
00:03:11,680 --> 00:03:16,080
server running all the time
87
00:03:13,920 --> 00:03:19,200
and to learn more about serverless
88
00:03:16,080 --> 00:03:20,879
functions because there is a lot you
89
00:03:19,200 --> 00:03:22,239
have to check out the course and learn
90
00:03:20,879 --> 00:03:24,159
more about the serverless functions
91
00:03:22,239 --> 00:03:26,319
there we will be using serverless
92
00:03:24,159 --> 00:03:28,799
functions throughout this course and
93
00:03:26,319 --> 00:03:30,799
diving into all the nitty-gritty details
94
00:03:28,799 --> 00:03:32,640
about serverless functions and i'm
95
00:03:30,799 --> 00:03:34,879
really excited for that because they are
96
00:03:32,640 --> 00:03:38,000
definitely my favorite
97
00:03:34,879 --> 00:03:40,720
so this is why next yes is known as the
98
00:03:38,000 --> 00:03:43,519
react framework for production because
99
00:03:40,720 --> 00:03:46,159
in order to make a production ready site
100
00:03:43,519 --> 00:03:49,200
you need to have all the necessary
101
00:03:46,159 --> 00:03:51,760
powerful tools to be able to do that
102
00:03:49,200 --> 00:03:54,640
and we won't just have any side we would
103
00:03:51,760 --> 00:03:57,599
have the best performance site out there
104
00:03:54,640 --> 00:04:00,080
and thanks to nexjs as we are able to go
105
00:03:57,599 --> 00:04:02,400
ahead and build front end as well as
106
00:04:00,080 --> 00:04:03,760
back end of your app in the same code
107
00:04:02,400 --> 00:04:07,599
base
108
00:04:03,760 --> 00:04:10,159
and also we get seo we get performance
109
00:04:07,599 --> 00:04:12,879
and we also get a lot of
110
00:04:10,159 --> 00:04:15,680
things that makes the life of developers
111
00:04:12,879 --> 00:04:18,639
so much easier
112
00:04:15,680 --> 00:04:21,359
all right so now that we have learned
113
00:04:18,639 --> 00:04:23,919
about serverless functions
114
00:04:21,359 --> 00:04:24,960
let's take a look at why nextgs is
115
00:04:23,919 --> 00:04:29,280
popular
116
00:04:24,960 --> 00:04:32,240
and if we have any doubts yet because
117
00:04:29,280 --> 00:04:35,800
we now know why it is popular right so
118
00:04:32,240 --> 00:04:35,800
let's take a look
8275
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.