Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,209 --> 00:00:04,470
Another very nice feature
2
00:00:04,470 --> 00:00:09,040
added by NextJS is file-based routing.
3
00:00:09,040 --> 00:00:10,590
Now what does this mean?
4
00:00:10,590 --> 00:00:14,820
In traditional React, you don't even have a router.
5
00:00:14,820 --> 00:00:16,040
And just to be clear,
6
00:00:16,040 --> 00:00:19,860
routing means that we give the user the illusion
7
00:00:19,860 --> 00:00:21,710
of having multiple pages.
8
00:00:21,710 --> 00:00:24,910
When we navigate around and we load different pages,
9
00:00:24,910 --> 00:00:27,290
then that's the job of a router.
10
00:00:27,290 --> 00:00:30,600
Typically we use React Router for that.
11
00:00:30,600 --> 00:00:34,940
This router basically watches the URL, and when it changes,
12
00:00:34,940 --> 00:00:37,480
it basically prevents the browser default
13
00:00:37,480 --> 00:00:40,680
of sending a request to some backend server,
14
00:00:40,680 --> 00:00:42,960
and instead renders different content
15
00:00:42,960 --> 00:00:44,890
on the page with React.
16
00:00:44,890 --> 00:00:47,330
A different component in the end.
17
00:00:47,330 --> 00:00:48,820
That's what routing is.
18
00:00:48,820 --> 00:00:51,020
We change what's visible on the screen
19
00:00:51,020 --> 00:00:55,600
based on the URL without sending a extra request to a server
20
00:00:55,600 --> 00:00:58,970
because we stay in that single page application
21
00:00:58,970 --> 00:01:02,030
which we typically build with React.
22
00:01:02,030 --> 00:01:05,269
Now that's routing, and typically with React,
23
00:01:05,269 --> 00:01:07,330
routing is set up in code.
24
00:01:07,330 --> 00:01:09,600
That code could look something like this,
25
00:01:09,600 --> 00:01:13,530
depending on the version of React Router you're using.
26
00:01:13,530 --> 00:01:16,130
Now this works and it's not bad, not wrong.
27
00:01:16,130 --> 00:01:18,220
React Router is a great package,
28
00:01:18,220 --> 00:01:21,060
but it is extra code which you have to write.
29
00:01:21,060 --> 00:01:25,090
And then often you end up storing your components
30
00:01:25,090 --> 00:01:29,330
that act as pages in a separate folder,
31
00:01:29,330 --> 00:01:33,630
which kind of replicates your route set up in code.
32
00:01:33,630 --> 00:01:37,780
So if you have three pages set up as pages and code,
33
00:01:37,780 --> 00:01:39,660
you have three page components
34
00:01:39,660 --> 00:01:41,670
in that pages component folder.
35
00:01:41,670 --> 00:01:43,380
Makes sense, I guess.
36
00:01:43,380 --> 00:01:44,890
Now since that's the case,
37
00:01:44,890 --> 00:01:49,300
NextJS gets rid of that in-code route definition.
38
00:01:49,300 --> 00:01:50,870
Instead, with NextJS,
39
00:01:50,870 --> 00:01:55,200
you would define pages and routes with files and folders.
40
00:01:55,200 --> 00:01:59,660
You have a special pages folder in NextJS apps
41
00:01:59,660 --> 00:02:02,010
which has to be named pages,
42
00:02:02,010 --> 00:02:06,080
and then you are structuring that folder,
43
00:02:06,080 --> 00:02:10,729
defines the routes and paths your page supports.
44
00:02:10,729 --> 00:02:11,563
And of course,
45
00:02:11,563 --> 00:02:15,430
we're also going to learn how that works in this course.
46
00:02:15,430 --> 00:02:18,790
Now that simply allows us to get rid of that extra code,
47
00:02:18,790 --> 00:02:20,570
and hence we have to write less code,
48
00:02:20,570 --> 00:02:24,530
we have less work, and it's a highly understandable concept
49
00:02:24,530 --> 00:02:25,940
because it's very close
50
00:02:25,940 --> 00:02:29,640
to how we all started with web development.
51
00:02:29,640 --> 00:02:32,200
When you're getting started with just HTML
52
00:02:32,200 --> 00:02:35,250
and CSS and some basic JavaScript maybe,
53
00:02:35,250 --> 00:02:37,600
then you build basic websites
54
00:02:37,600 --> 00:02:40,150
by adding multiple HTML files,
55
00:02:40,150 --> 00:02:42,460
and the names of these files
56
00:02:42,460 --> 00:02:44,970
or the folders in which they sit
57
00:02:44,970 --> 00:02:47,900
define how you can navigate between these files.
58
00:02:47,900 --> 00:02:50,210
How you can link these files together.
59
00:02:50,210 --> 00:02:53,600
And NextJS basically allows us to go back
60
00:02:53,600 --> 00:02:58,600
to this very basic, yet understandable concept of routing.
61
00:02:58,700 --> 00:03:02,770
And NextJS still supports all the features we might want,
62
00:03:02,770 --> 00:03:07,060
like nested routes or dynamic routes with dynamic parameters
63
00:03:07,060 --> 00:03:08,020
and all of that.
64
00:03:08,020 --> 00:03:11,203
And we're going to see that in this course, of course.
5019
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.