Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,050 --> 00:00:03,400
Now to write some code.
2
00:00:03,400 --> 00:00:07,950
I'm back here in an empty Next.js project,
3
00:00:07,950 --> 00:00:11,180
which you again find attached to this lecture
4
00:00:11,180 --> 00:00:15,023
so that we all start with exactly the same starting state.
5
00:00:16,020 --> 00:00:18,680
It's very similar to the starting projects
6
00:00:18,680 --> 00:00:20,510
from the last core sections,
7
00:00:20,510 --> 00:00:23,640
but I did already add an index.js file
8
00:00:23,640 --> 00:00:28,150
in the pages folder, which lists some dummy content.
9
00:00:28,150 --> 00:00:32,710
Now if we run NPM installed here to install all dependencies
10
00:00:32,710 --> 00:00:34,450
and then we run NPM run dev,
11
00:00:34,450 --> 00:00:37,420
we bring up that development server again.
12
00:00:37,420 --> 00:00:38,350
And once I do that,
13
00:00:38,350 --> 00:00:40,970
we see product one, product two, product three,
14
00:00:40,970 --> 00:00:44,690
and that's just the dummy content I have in there.
15
00:00:44,690 --> 00:00:48,440
Now before we add this get static props function,
16
00:00:48,440 --> 00:00:51,880
I already want to show you something important.
17
00:00:51,880 --> 00:00:55,530
If we view the page source of this page here,
18
00:00:55,530 --> 00:00:59,380
so of this page generated by Next.js,
19
00:00:59,380 --> 00:01:01,970
then we see that it looks very different
20
00:01:01,970 --> 00:01:04,239
than what we had a look at before
21
00:01:04,239 --> 00:01:06,720
with the Standard React App.
22
00:01:06,720 --> 00:01:08,650
And while this is a bit hard to read,
23
00:01:08,650 --> 00:01:11,150
we see that in there, indeed,
24
00:01:11,150 --> 00:01:15,610
we do have the unordered list with the list items here.
25
00:01:15,610 --> 00:01:16,940
Here it is.
26
00:01:16,940 --> 00:01:21,280
We do have that in here in this page.
27
00:01:21,280 --> 00:01:24,630
And keep in mind that this page source we're seeing here
28
00:01:24,630 --> 00:01:28,460
is the actual response we got back from the server,
29
00:01:28,460 --> 00:01:30,820
in this case from the development server,
30
00:01:30,820 --> 00:01:32,700
when this page was loaded.
31
00:01:32,700 --> 00:01:35,680
When this request was initially sent.
32
00:01:35,680 --> 00:01:37,950
And that is the kind of content
33
00:01:37,950 --> 00:01:40,290
a search engine would see as well.
34
00:01:40,290 --> 00:01:41,500
And that's of course great.
35
00:01:41,500 --> 00:01:44,280
It already contains the content.
36
00:01:44,280 --> 00:01:46,240
Of course, this is not content
37
00:01:46,240 --> 00:01:49,350
that was fetched with use effect or anything like that,
38
00:01:49,350 --> 00:01:52,920
but before in the React app, we didn't see any content,
39
00:01:52,920 --> 00:01:56,460
not just the content that was fetched with use effect.
40
00:01:56,460 --> 00:01:59,150
We also didn't see an empty unordered list.
41
00:01:59,150 --> 00:02:01,640
We saw no content at all.
42
00:02:01,640 --> 00:02:04,830
Now, we see all the HTML code,
43
00:02:04,830 --> 00:02:08,490
all the JSX code, returned by our component.
44
00:02:08,490 --> 00:02:10,120
We see that here.
45
00:02:10,120 --> 00:02:13,170
And that already shows us that there is a difference.
46
00:02:13,170 --> 00:02:15,620
This page, which we're getting here,
47
00:02:15,620 --> 00:02:20,620
with Next.js was already pre-rendered by Next.js
48
00:02:21,450 --> 00:02:23,640
without us doing anything.
49
00:02:23,640 --> 00:02:27,420
It was already pre-rendered because by default,
50
00:02:27,420 --> 00:02:32,420
Next.js pre-renders all pages that have no dynamic data.
51
00:02:34,000 --> 00:02:37,550
And this page of course does not have any dynamic data,
52
00:02:37,550 --> 00:02:40,060
everything here is just hard coded.
53
00:02:40,060 --> 00:02:41,850
And if you have a page like this,
54
00:02:41,850 --> 00:02:45,483
Next.js will automatically pre-render it for you.
55
00:02:46,350 --> 00:02:49,000
Which is great because now any content
56
00:02:49,000 --> 00:02:51,140
which you encode in your component
57
00:02:51,140 --> 00:02:53,400
will be visible to search engines,
58
00:02:53,400 --> 00:02:57,560
and to your website visitors, right from the start.
59
00:02:57,560 --> 00:03:00,370
So that's not even the main thing of this section,
60
00:03:00,370 --> 00:03:01,963
but it's already important.
61
00:03:02,820 --> 00:03:06,333
However, let's now get back to get static props.
4800
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.