跟读练习: Next.js in 100 Seconds // Plus Full Beginner's Tutorial - 通过视频学习英语口语

选择练习模式

每种模式都会打开全屏练习室。

163 句
如果句子过短或过长,请点击 Edit 进行调整。
1
Next .js, create fast, search engine optimized
2
React apps with zero configuration.
3
A traditional React app is rendered client -side, where the browser starts with a shell of an HTML page lacking any rendered content.
4
From there, the browser fetches the JavaScript file containing the React code to render content to the page and make it interactive.
5
But there are two major drawbacks with client -side rendering.
6
One, the content is not reliably indexed by all search engines or read by social media linkbots.
7
And two, it can take longer to reach the first contentful paint when a user first lands on the web page.
8
Next is a framework that allows you to build a React app, but render the content in advance on the server,
9
so the first thing a user or a search bot sees is the fully rendered HTML.
10
After receiving this initial page, client -side rendering takes over, and it works just like a traditional React app.
11
It's the best of both worlds.
12
Fully rendered content for bots, highly interactive content for users.
13
Inside of a Next project, you have a Pages directory.
14
Each JavaScript file defined here exports a React component that represents a route in the application.
15
In other words, the file structure here mirrors the actual URLs that the user will navigate to,
16
and Next provides its own router to make navigation seamless.
17
But the real magic comes into play when we talk about data fetching, because Next can perform multiple server rendering strategies from a single project.
18
Static generation, or pre -rendering, allows you to render your pages at build time.
19
Each page or component can implement a function called getStaticProps.
20
It might fetch data from a cloud database, then pass the data as props to the component.
21
You can then build your app to render out all the HTML locally
22
and upload it to a storage bucket where it can be easily cached by a CDN.
23
That works great for a blog or any kind of app where the data doesn't change often.
24
But if the data does change often, you can implement server -side rendering, which builds the HTML page each time it's requested by the user.
25
In the component, we implement data fetching with the getServerSideProps function.
26
Instead of running at build time, this function runs at request time.
27
That means the page will fetch the latest data on the server each time a new request comes in.
28
That's great for pages with rapidly changing data, but maybe you want something in between.
29
Yet another option is incremental static regeneration.
30
By simply adding a revalidate option to get static props, Next can regenerate a page whenever a new request comes in within a certain time interval.
31
This has been Next .js in 100 seconds.
32
If you want to see more short videos like this, make sure to subscribe and hit the like button.
33
Then open up VS Code and get ready to go beyond 100 seconds with a full breakdown of Next.
34
Before we get going, I'd like to point out that I'm working on a full
35
React Next Firebase course, which I hope to have finally finished by the end of January, which will be available to Fireship Pro members.
36
My goal over the next few minutes is to teach you the fundamentals of Next
37
while also explaining the complexities of server side rendering.
38
To follow along, open up the terminal and run npx create next app followed by the name of your app.
39
And if you get lost at any point, make sure to grab the source code on GitHub or Fireship IO.
40
Let's open up the project in VS Code and then go into the package .json file.
41
In development, the only script we need to worry about is dev, which you can execute by running npm run dev from the command line,
42
which will run our app on localhost 3000.
43
That should give you the default boilerplate in the browser.
44
Now before we get into the React code, there's a few things that I want to point out.
45
First, in the styles directory here, you'll notice how
46
Next supports CSS modules.
47
In the globals file, you can define styles that apply to the entire application.
48
But in other files with .module, you can define classes that only apply to a specific route or component.
49
And you don't have to worry about coming up with a bunch of unique class names
50
or naming conventions when managing your styles.
51
If you want to use styles from a certain module, you just import the style sheet in your JavaScript,
52
then reference your styles in JSX as if the styles were a JavaScript object.
53
That's pretty awesome, but from there, let's shift our attention over to the pages directory.
54
Inside this directory, we define all of the pages and routes for the application.
55
At the highest level, we have this underscore app .js file, which is like the main entry point into the app.
56
In other words, every individual page will start from this template.
57
Currently, the application only has one page, which points to the root URL and is defined by the component in the index .js file.
58
When a user navigates to this URL, next will find the default export, which is a React component, in this file.
59
So every file or page in your application needs to have one default export.
60
To demonstrate this further, let's create our first route.
61
In the pages directory, create a new file called hello .js.
62
Then we can define the content of this page by exporting
63
a default react component from it from there we can go back to the browser
64
and navigate to localhost 3000 slash hello and we should get the content of
65
that component congratulations you just built your first web page with next
66
but now let's imagine a route that's a little more complex we have a cars route
67
that should show a list of cars then an infinite number of cars
68
that might be dynamically generated under that url we can implement a dynamic route like that by first creating a cars directory.
69
Then inside the directory, we'll add an index .js file.
70
which will show the main list of cars.
71
Then for each individual car, we'll add a component that has a file name of brackets param name dot j s.
72
The brackets make this route dynamic, which means anytime a user navigates to cars slash whatever, or cars slash
73
Tesla, it will render the component in this file.
74
To see that in action, let's go ahead and implement the component logic.
75
In the index file, we'll just add a placeholder for the cars list for now.
76
But in the dynamic component, we'll import the useRouter hook from the next router.
77
It allows us to access the query parameters from the URL.
78
In this example, the value is ID, but you can give it a name of whatever you want.
79
And then we'll render that value out to the template.
80
Now back in the browser, if we go to the cars URL, it renders out the cars component.
81
Then if we add any string after the cars URL, it renders out the dynamic component.
82
Now one other thing you may have noticed in the pages directory is this API directory.
83
So what is that all about?
84
The API directory is a special part of Next for setting up routes that will only apply to the server.
85
That can be useful because the code you write here won't increase the client -side JavaScript bundle
86
that needs to ultimately be sent over the network.
87
We're not going to get into API routes in this video,
88
but just know that it's a useful feature when you have work that needs to be done on the backend,
89
or if you simply want to expose an API for your end users.
90
But now, let's shift our attention over to the most valuable feature in Next, which of course is data fetching.
91
Next allows us to fetch data and render HTML on the server.
92
And again, the benefit of doing that is
93
that the end user gets rendered content quicker
94
and the content can be reliably crawled by search bots and social media link bots.
95
Now, when it comes to server rendering, there are two main options, static generation and server -side rendering.
96
Static generation is also called pre -rendering because you generate all the HTML at build time.
97
It makes life very simple because you generate a bunch of HTML files, then upload them to a storage bucket or static host,
98
and they can be delivered with very high performance over a CDN.
99
But there's a couple of big trade -offs here.
100
The first one is that your data may become stale.
101
If the data on the server changes, you need to rebuild and redeploy your site in order for those changes to be reflected.
102
Another important trade -off to think about is scale.
103
If your website has a million pages, it'll be very slow and difficult to pre -render all of them.
104
That makes static generation most well -suited for data
105
that doesn't change often and for sites that have a relatively low number of total pages.
106
A good example would be a blog, because it might have a few hundred pages and those pages likely don't change on a daily basis.
107
Let's go ahead and take a look at how we might implement static generation in Next.
108
In the car component, let's imagine we need to fetch data from an external source, like a database or API.
109
To simulate that for the demo, I've added a couple of JSON files to the public directory.
110
We have a file that returns an array of IDs, then an individual response for each car,
111
which contains an image and other data about the car.
112
Now we can fetch this data for the car component by implementing the get static props function inside the component file.
113
When you build your site, Next will automatically call this function, then send the result as props to the component itself.
114
What we want to do here is fetch the JSON for an individual car
115
so it can be used in the HTML or UI for the car page.
116
In this case, we need the ID from the URL to know which car was requested.
117
We can get that information from the params argument in the function.
118
Then from there, we'll use the fetch API to make a request to localhost to request the JSON file with that ID.
119
We can then convert it to JSON.
120
Then the final step is to return an object that has a props property, where each prop can then be accessed by the component.
121
Up in the component code, we can destructure the car prop and then use it in the JSX,
122
which I'm doing here by adding an image tag, which relies on the data fetched by the server as the image source.
123
Now if you're concerned about search engine optimization,
124
you likely want to add an SEO -friendly title as well as meta tags to the head of the document.
125
Next makes that very easy to accomplish by simply importing the head component.
126
Anything inside this component will be rendered out to the head of the document.
127
Like in this case, we add a title with the car color and ID.
128
And we could also add meta tags for Twitter and Facebook cards if we wanted to.
129
Now because we're working with a dynamic route, there's one other thing we have to keep in mind.
130
And that's the fact that
131
Next has no way of knowing how many pages we actually have associated to a dynamic route.
132
In order to pre -render all the car IDs, Next needs to know those IDs in advance.
133
And the way we provide that information is by implementing the get static paths function.
134
This function can also request data from an API or database,
135
then its job is to return a paths object that contains an array with every route for this dynamic URL.
136
In this demo, we only have three routes, Tesla, Ford, and Lambo.
137
We map those values to an array of objects, then return them from the function, along with additional options like the fallback behavior.
138
Now if we go visit the app in the browser.
139
we should see a fully rendered web page.
140
It doesn't look any different than a regular React app.
141
However, if you open up the Sources panel in Chrome DevTools, it'll show you the fully rendered HTML before it was touched by JavaScript.
142
Notice how it contains the title and pre -rendered content, which is essential for SEO and sharing content on social media sites.
143
So that's how you implement server -side generation.
144
But another big strategy is server -side rendering.
145
The big difference is that with SSR, the content is generated on a server when requested by the user.
146
This approach is ideal when data changes constantly
147
because it ensures the end user will always get the latest and greatest data from whatever your data source happens to be.
148
However, it's far less efficient because you need to have a server in place to respond to those requests,
149
as opposed to caching everything on a global CDN.
150
Imagine something like an eBay auction where you have millions of listings and those listings are changing all the time.
151
That's probably a good candidate for SSR.
152
In any case, it's very easy to implement a Next.
153
Back in our page file, we'll go ahead and implement another function called getServerSideProps.
154
The only thing that actually changes in our code is the name of the function.
155
We can simply copy the body of the getStaticProps function and paste it into our new function.
156
It does the exact same thing, but does it on every request instead of at build time.
157
Then we can comment out getStaticProps and getStaticPaths because we no longer need those functions.
158
But the real beauty of Next is that we can apply both of these paradigms wherever we want in the application.
159
We're not limited to one or the other.
160
I'm going to go ahead and wrap things up there.
161
If there's anything you want to see in my full
162
Next course, make sure to let me know in the comments.
163
Thanks for watching, and I will see you in the next one.

下载应用

流利口语所需的一切

AI 发音评分逐句打分
音标练习掌握每个音
词汇学习建立你的词库
词汇游戏边玩边学

同频道

FOR YOU

推荐视频

本课的词汇与口语要点

这节口语课以视频“Next.js in 100 Seconds // Plus Full Beginner's Tutorial”为素材。 视频中反复出现的词有:page, component, file, server, route。 这段视频共有 163 个句子、2418 个单词可供跟读。 讲话部分时长为 11:49。 说话人语速较快,每分钟约 205 个词,会出现较多连读和弱读。 只有 80% 的单词属于英语最常用的 3,000 词,词汇难度较高。

视频中的重点词汇

视频中 15 个值得学习的单词,附发音和释义:

单词发音释义
component 名词/kəmˈpoʊ.nənt/元件, 部件
server 名词/ˈsɝvɚ/服務器 /服务器, 伺服器
fetch 动词/fɛt͡ʃ/取
implement 动词/ˈɪmpləmənt/實施 /实施, 執行 /执行
directory 名词/dɪˈɹɛktəɹi/名錄 /名录, 簿
define 动词/dɪˈfaɪn/界定
default 名词/dɪˈfɔlt/違約 /违约, 暴雷
export 名词/ˈɛks.pɔɹt/出口, 輸出 /输出
database 名词/ˈdeɪtəˌbeɪs/數據庫 /数据库
import 名词/ˈɪm.pɔɹt/進口貨 /进口货, 舶來品 /舶来品
module 名词/ˈmɑd͡ʒul/模塊 /模块
bot 名词/bɑt/機器人 /机器人
tag 名词/tæɡ/標簽 /标签
bucket 名词/ˈbʌkɪt/水桶, 吊桶
demo 名词/ˈdɛm.oʊ/示範 /示范

视频中出现的短语动词

单词发音释义
go ahead 动词/ˌɡoʊ əˈhɛd/請便 /请便
point out 动词指, 指出
come up with 动词想出, 提出
take over 动词接管, 接手

视频中的语法

说话人最常用的结构,并附上视频中的原话:

结构视频中的用法
被动语态 be + 过去分词 — 强调发生了什么,而不是谁做的is rendered · is not reliably indexed · can be easily cached
定语从句 who / which + 从句 — 补充说明人或事物January, which will · file, which is · export, which is
现在完成时 have/has + 过去分词 — 过去发生但与现在仍有关联的事has been · I've added · have associated

需要注意的发音

说话人用了 25 次缩略和弱读形式,例如 we'll, doesn't, I'm。请按听到的简短形式来说。

  • “sh” 和 “zh” 音: cache /kæʃ/, efficient /ɪˈfɪʃənt/, congratulations /kənˌɡɹæt͡ʃəˈleɪʃ(ə)nz/, sheet /ʃit/, shell /ʃɛl/
  • 长单词——注意重音位置: directory /dɪˈɹɛktəɹi/, interactive /ˌɪn.tɚˈæk.tɪv/, congratulations /kənˌɡɹæt͡ʃəˈleɪʃ(ə)nz/, fundamental /ˌfʌn.dəˈmɛn.təl/, navigation /nævɪˈɡeɪʃən/

中文母语者容易读错的音:

  • /v/ — 不要读成 /w/,上齿轻触下唇: server /ˈsɝvɚ/, navigate /ˈnæv.ɪ.ɡeɪt/, interactive /ˌɪn.tɚˈæk.tɪv/, wherever /(h)wɛɹˈɛvɚ/, convert /kənˈvɝt/
  • 词尾辅音 — 要读清楚,后面不要加元音: component /kəmˈpoʊ.nənt/, fetch /fɛt͡ʃ/, implement /ˈɪmpləmənt/, react /ɹiːˈækt/, static /ˈstæt.ɪk/
  • /r/ 和 /l/ 的区别: congratulations /kənˌɡɹæt͡ʃəˈleɪʃ(ə)nz/, reflect /ɹɪˈflɛkt/, rapidly /ˈɹæpɪdli/, rely /ɹɪˈlaɪ/, rebuild /ɹiːˈbɪld/

如何用这段视频练习

  1. 先完整听一遍视频,不要开口,记下不认识的单词。
  2. 先用 0.75 倍速逐句跟读,熟练之后再回到正常速度。
  3. 录下自己的声音并与原声对比,特别注意 component, server, fetch 这类单词。

什么是跟读法?

跟读法 (Shadowing) 是一种有科学依据的语言学习技巧,最初开发用于专业口译员的培训,并由多语言者Alexander Arguelles博士普及。这个方法简单而强大:您在听英语母语原声的同时立即大声重复——就像是一个延迟1-2秒紧跟说话者的影子。与被动听力或语法练习不同,跟读法强迫您的大脑和口腔肌肉同时处理并模仿真实的讲话模式。研究表明它能显着提高发音准确性,语调,节奏,连读,听力理解和口语流利度——使其成为雅思口语备考和真实英语交流最有效的方法之一。

影子跟读法: 阅读完整分步指南 →