<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nextjser</title>
    <description>The latest articles on DEV Community by Nextjser (@nextjser).</description>
    <link>https://dev.to/nextjser</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1998769%2Fb4fcf281-3dab-4daf-b90f-bc418b2f2657.png</url>
      <title>DEV Community: Nextjser</title>
      <link>https://dev.to/nextjser</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nextjser"/>
    <language>en</language>
    <item>
      <title>I'm developing a new note app. It's in testing now. Come try it!🚀</title>
      <dc:creator>Nextjser</dc:creator>
      <pubDate>Mon, 14 Apr 2025 03:39:15 +0000</pubDate>
      <link>https://dev.to/nextjser/im-developing-a-new-note-app-its-in-testing-now-come-try-it-16ia</link>
      <guid>https://dev.to/nextjser/im-developing-a-new-note-app-its-in-testing-now-come-try-it-16ia</guid>
      <description>&lt;p&gt;Hi everyone, I’m the creator of &lt;a href="https://cogo.im/" rel="noopener noreferrer"&gt;Cogo&lt;/a&gt;, a next-generation note-taking app designed to transform how we create, share, and grow knowledge together. Let me walk you through what makes Cogo more than just another note-taking tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdwldpzdbzytrxgbv1fd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdwldpzdbzytrxgbv1fd.png" alt="Image description" width="192" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cogo at a Glance
&lt;/h2&gt;

&lt;p&gt;Cogo is a bidirectionally linked Markdown note app that blends personal knowledge management with collaborative learning. While it lets you organize thoughts with familiar features like backlinks and Markdown formatting, its true power lies in its public knowledge ecosystem. Every note you create can be shared as a link, published to Cogo’s communal space, and even spark conversations with others. Think of it as a hybrid between your private notebook and a dynamic, crowd-sourced encyclopedia.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6fcu15fh9f1dbztixyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6fcu15fh9f1dbztixyl.png" alt="Image description" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Features
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bidirectional Link&lt;/strong&gt;&lt;br&gt;
Create connections between ideas effortlessly. Click any highlighted term to dive deeper into related concepts, definitions, or community discussions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Public Knowledge Commons&lt;/strong&gt;&lt;br&gt;
Share notes to Cogo’s open platform, where others can read, discuss, and remix your ideas into their own work. Public notes become building blocks for collective understanding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaborative Learning&lt;/strong&gt;&lt;br&gt;
Ask questions, crowdsource answers, refine ideas, and even co-author content with like-minded learners.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why Share Knowledge on Cogo?
&lt;/h2&gt;

&lt;p&gt;When you publish your notes to Cogo’s public space, you’re not just storing information—you’re contributing to a living, evolving knowledge network. Here’s how it works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌱 Build a Collective Brain&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every shared note becomes a node in Cogo’s interconnected knowledge graph. Bidirectional links let users expand on ideas, creating rich, layered explanations. Over time, this grows into a self-improving repository of wisdom.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎯 Grow Your Influence&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Share expertise to attract followers. When others reference your notes, your ideas spread organically—and your audience grows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❓ Solve Problems Faster&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stuck on a question? Post it publicly. Someone with the right knowledge might already have the answer (or collaborate with you to find it).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚡️ Amplify Your Impact&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your note helps others, they can embed it directly into their work. No rewriting, no credit battles—just seamless knowledge reuse. You gain visibility; they save time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🤝 Co-Create &amp;amp; Refine&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Turn brainstorming into a team sport. Share drafts, invite feedback, or crowdsource perspectives to refine ideas collectively. Even errors become opportunities: the community can fact-check and improve your notes over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cogo’s Vision
&lt;/h2&gt;

&lt;p&gt;Imagine a world where knowledge isn’t trapped in silos but flows freely, connecting curious minds. Cogo aims to be more than a tool—it’s a movement toward open, collaborative learning. Whether you’re a student, professional, or lifelong learner, your contributions shape this ecosystem.&lt;/p&gt;

&lt;p&gt;Ready to Join the Evolution?&lt;br&gt;
Click the &lt;a href="https://cogo.im/login" rel="noopener noreferrer"&gt;login&lt;/a&gt; and start building the future of knowledge—one linked note at a time. ✨&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cogo.im/post/209f18b6-89be-40f9-ba29-651216e57d15" rel="noopener noreferrer"&gt;Cogo Beginner's Tutorial&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>This Next.js blog template is awesome.</title>
      <dc:creator>Nextjser</dc:creator>
      <pubDate>Fri, 11 Oct 2024 16:28:35 +0000</pubDate>
      <link>https://dev.to/nextjser/this-nextjs-blog-template-is-awesome-ija</link>
      <guid>https://dev.to/nextjser/this-nextjs-blog-template-is-awesome-ija</guid>
      <description>&lt;h2&gt;
  
  
  Introduce
&lt;/h2&gt;

&lt;p&gt;Let me introduce to you a user-friendly personal blog template for Next.js, called &lt;a href="https://github.com/timlrx/tailwind-nextjs-starter-blog" rel="noopener noreferrer"&gt;Tailwind Nextjs Starter Blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frso2xeddmo97zqo3pvch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frso2xeddmo97zqo3pvch.png" alt="tailwind-nextjs-starter-blog" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Probably the most feature-rich Next.js markdown blogging template out there. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Next.js with Typescript&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.contentlayer.dev/" rel="noopener noreferrer"&gt;Contentlayer&lt;/a&gt; to manage content logic&lt;/li&gt;
&lt;li&gt;Easy styling customization with &lt;a href="https://tailwindcss.com/blog/tailwindcss-v3" rel="noopener noreferrer"&gt;Tailwind 3.0&lt;/a&gt; and primary color attribute&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mdxjs.com/" rel="noopener noreferrer"&gt;MDX - write JSX in markdown documents!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Near perfect lighthouse score - &lt;a href="https://www.webpagetest.org/result/230805_BiDcBQ_4H7" rel="noopener noreferrer"&gt;Lighthouse report&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Lightweight, 85kB first load JS&lt;/li&gt;
&lt;li&gt;Mobile-friendly view&lt;/li&gt;
&lt;li&gt;Light and dark theme&lt;/li&gt;
&lt;li&gt;Font optimization with &lt;a href="https://nextjs.org/docs/app/api-reference/components/font" rel="noopener noreferrer"&gt;next/font&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Integration with &lt;a href="https://github.com/timlrx/pliny" rel="noopener noreferrer"&gt;pliny&lt;/a&gt; that provides:

&lt;ul&gt;
&lt;li&gt;Multiple analytics options including &lt;a href="https://umami.is/" rel="noopener noreferrer"&gt;Umami&lt;/a&gt;, &lt;a href="https://plausible.io/" rel="noopener noreferrer"&gt;Plausible&lt;/a&gt;, &lt;a href="https://simpleanalytics.com/" rel="noopener noreferrer"&gt;Simple Analytics&lt;/a&gt;, Posthog and Google Analytics&lt;/li&gt;
&lt;li&gt;Comments via &lt;a href="https://github.com/laymonage/giscus" rel="noopener noreferrer"&gt;Giscus&lt;/a&gt;, &lt;a href="https://github.com/utterance/utterances" rel="noopener noreferrer"&gt;Utterances&lt;/a&gt; or Disqus&lt;/li&gt;
&lt;li&gt;Newsletter API and component with support for Mailchimp, Buttondown, Convertkit, Klaviyo, Revue, Emailoctopus and Beehiiv&lt;/li&gt;
&lt;li&gt;Command palette search with &lt;a href="https://github.com/timc1/kbar" rel="noopener noreferrer"&gt;Kbar&lt;/a&gt; or Algolia&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Server-side syntax highlighting with line numbers and line highlighting via &lt;a href="https://github.com/timlrx/rehype-prism-plus" rel="noopener noreferrer"&gt;rehype-prism-plus&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;Math display supported via &lt;a href="https://katex.org/" rel="noopener noreferrer"&gt;KaTeX&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;Citation and bibliography support via &lt;a href="https://github.com/timlrx/rehype-citation" rel="noopener noreferrer"&gt;rehype-citation&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;

&lt;a href="https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts" rel="noopener noreferrer"&gt;Github alerts&lt;/a&gt; via &lt;a href="https://github.com/jaywcjlove/remark-github-blockquote-alert" rel="noopener noreferrer"&gt;remark-github-blockquote-alert&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;Automatic image optimization via &lt;a href="https://nextjs.org/docs/basic-features/image-optimization" rel="noopener noreferrer"&gt;next/image&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;Support for tags - each unique tag will be its own page&lt;/li&gt;

&lt;li&gt;Support for multiple authors&lt;/li&gt;

&lt;li&gt;3 different blog layouts&lt;/li&gt;

&lt;li&gt;2 different blog listing layouts&lt;/li&gt;

&lt;li&gt;Support for nested routing of blog posts&lt;/li&gt;

&lt;li&gt;Projects page&lt;/li&gt;

&lt;li&gt;Preconfigured security headers&lt;/li&gt;

&lt;li&gt;SEO friendly with RSS feed, sitemaps and more!&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use the template
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.best-switch-games.com/" rel="noopener noreferrer"&gt;Best Switch Games&lt;/a&gt; is what I created with this template. Find the best Nintendo Switch games all in one place. Looks good, doesn't it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fip9yzbq4jxre8tb5vuyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fip9yzbq4jxre8tb5vuyc.png" alt="Best Switch Games" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
    </item>
    <item>
      <title>June Programming Language Rankings</title>
      <dc:creator>Nextjser</dc:creator>
      <pubDate>Tue, 10 Sep 2024 07:30:59 +0000</pubDate>
      <link>https://dev.to/nextjser/june-programming-language-rankings-2bcj</link>
      <guid>https://dev.to/nextjser/june-programming-language-rankings-2bcj</guid>
      <description>&lt;p&gt;The latest TIOBE Programming Community index for June 2024 has been released, as shown in the figure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fna3o5lax6xy6qqvrpabq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fna3o5lax6xy6qqvrpabq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The TIOBE Programming Community index is calculated based on the number of engineers worldwide, courses, popular websites, and third-party vendors, and it reflects the popularity and trends of programming languages. It does not represent the superiority or inferiority of the languages.&lt;/p&gt;

&lt;p&gt;Here are the key changes in this ranking:&lt;/p&gt;

&lt;h2&gt;
  
  
  June 24 Programming Language Ranking Changes
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. Python remains at the top
&lt;/h4&gt;

&lt;p&gt;A long time ago, Python had already secured its position at the top of the rankings, and this time it has increased by 2.93%. What does that mean? The score it gained this month is higher than the total score of the Go language!&lt;/p&gt;

&lt;p&gt;This was predictable, as Python, with its simple and easy-to-learn syntax and wide range of applications such as data science, machine learning, web development, and web crawling, has attracted a large number of developers. The recent boom in AI has also given Python another boost.&lt;/p&gt;

&lt;p&gt;For friends who are learning programming languages as a hobby, Python is a good choice. However, considering job prospects in China, there are many fewer positions for Python in web development compared to Java, making it more suitable for those interested in big data, algorithms, and product development.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. C++ Surpasses C Language for the First Time in History
&lt;/h4&gt;

&lt;p&gt;The most significant change in this ranking is that C++ has surpassed the C language for the first time, jumping to second place.&lt;/p&gt;

&lt;p&gt;C++ can be understood as the "advanced version" of C language, offering not only high performance but also support for object-oriented programming and many new features.&lt;/p&gt;

&lt;p&gt;I believe it is inevitable that C++'s popularity has surpassed that of C, just as the relationship between Java and C++. In today's environment, languages that are easier to use are more likely to be favored by the majority of developers.&lt;/p&gt;

&lt;p&gt;The rise of C++ is mainly due to its high performance and modern features. Although it is more difficult to learn than Java, its key position in high-performance application scenarios such as system programming, game development, image processing, and audio and video processing is unshakable. In addition, C++ is also a mainstream language for embedded development and desktop client development.&lt;/p&gt;

&lt;p&gt;As for whether to choose C++ or Java for job prospects in China, it depends on individual perspectives. I wrote an article a long time ago to share my views.&lt;/p&gt;

&lt;p&gt;The TIOBE index change chart for C++:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6oe3a6qwhupxvpsx8l50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6oe3a6qwhupxvpsx8l50.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Go Language Breaks into the Top 7
&lt;/h4&gt;

&lt;p&gt;In the past year, the ranking of Go language has rapidly climbed from 14th to 7th, which is also worth our attention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffti3nty7ku0uwr2y1jky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffti3nty7ku0uwr2y1jky.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The advantages of Go language are its concise syntax and high performance. Its built-in concurrency mechanism makes concurrent programming simple and efficient, which is why it is widely used in the development of network programming, cloud computing, microservices, and distributed systems.&lt;/p&gt;

&lt;p&gt;For most of our developer friends, an obvious advantage of Go language is the incredibly fast project startup speed. Traditional Spring Boot Java projects may take more than ten seconds to start, while Go language might take less than 1 second, making it very suitable for rapid scaling in cloud-native scenarios. We are familiar with projects like Docker, K8S, and Etcd, all of which are developed using Go language.&lt;/p&gt;

&lt;p&gt;Java has also long felt the threat from Go language, hence the introduction of cloud-native development frameworks like Quarkus. I have played around with it for a while, and the project startup speed is also very fast, but the ecosystem is not yet mature.&lt;/p&gt;

&lt;p&gt;Nowadays, the community and ecosystem of Go language are becoming more and more prosperous, with many libraries, frameworks, and tools already in place. Therefore, more and more companies both domestically and internationally are using Go language, and this ranking is not surprising.&lt;/p&gt;

&lt;p&gt;As a result, there is a voice in the domestic community forums: Should we switch from Java to Go language?&lt;/p&gt;

&lt;p&gt;My suggestion is not to switch blindly. Students with strong self-learning abilities, if you have not yet touched Java, can start learning from Go; but students with average self-learning abilities, it is better to stick with learning Java, because the resources for learning Java in China are too abundant, with various tutorials, projects, and experience posts, which Go language cannot compare with. Moreover, both Java and Go are currently mainstream in backend development scenarios. For backend development, the language is just a tool and foundation. In addition to the language itself and the corresponding development frameworks, other backend development technologies to be learned are universal, such as databases, caching, queues, search engines, Linux, distributed systems, high concurrency, design patterns, architectural design, and so on. So, it is more helpful to learn the more resource-rich Java first to quickly get in touch with other technologies.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Some Emerging Languages
&lt;/h4&gt;

&lt;p&gt;By comparing with last year, we can identify some rapidly developing programming languages, such as Rust, which has reached its highest historical ranking of 17th place. Known for its memory safety and high performance, Rust is increasingly taking a share in the systems programming domain that has traditionally been dominated by C/C++.&lt;/p&gt;

&lt;p&gt;In addition, the rankings of languages like Swift, Kotlin, and Fortran have also significantly improved, as shown in the comparison chart between 2024 and 2023:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy7l327stres5lokddd62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy7l327stres5lokddd62.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Rankings
&lt;/h2&gt;

&lt;p&gt;Finally, let's share the other rankings from the TIOBE Programming Community index to help everyone understand the development trends.&lt;/p&gt;

&lt;h4&gt;
  
  
  Programming languages ranked 21st to 50th.
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5uboysifu7ve6aq3jo5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5uboysifu7ve6aq3jo5m.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Programming languages ranked 51st to 100th:
&lt;/h4&gt;

&lt;p&gt;ABC, ActionScript, Apex, APL, AutoLISP, bc, CFML, Chapel, CHILL, CLIPS, Clojure, COMAL, Crystal, cT, Elixir, Erlang, Forth, Groovy, Hack, Icon, Inform, Io, J, JScript, Ladder Logic, Lingo, LPC, M4, MEL, Modula-2, Mojo, NATURAL, NetLogo, OpenCL, OpenEdge ABL, PowerScript, Programming Without Coding Technology, Q, RPG, Smalltalk, Smarty, SNOBOL, SPARK, SQR, VHDL, WebDNA, Wolfram, X++, X10, yacc&lt;/p&gt;

&lt;p&gt;It's a bit of a pity about Erlang; despite having a well-known product like RabbitMQ, it hasn't quite caught on.&lt;/p&gt;

&lt;h4&gt;
  
  
  Historical Programming Language Rankings
&lt;/h4&gt;

&lt;p&gt;The evolution of popular programming language rankings from 1989 to 2024:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fep8o2jp3esr8lrm7nxdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fep8o2jp3esr8lrm7nxdo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OK, that's it for the share. What are your thoughts on the June programming language rankings? Feel free to speak your mind in the comments section~&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>c</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Why is Next.js's routing so odd?</title>
      <dc:creator>Nextjser</dc:creator>
      <pubDate>Wed, 04 Sep 2024 03:54:47 +0000</pubDate>
      <link>https://dev.to/nextjser/why-is-nextjss-routing-so-odd-5dlp</link>
      <guid>https://dev.to/nextjser/why-is-nextjss-routing-so-odd-5dlp</guid>
      <description>&lt;p&gt;Next.js is a full-stack framework for React, primarily focused on server-side rendering (SSR). It has a very powerful, yet somewhat unusual, routing mechanism. What does this routing mechanism look like? And why is it considered strange? Let's try it out and see. First, let's create a Next.js project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsn6w8kt8f08fyvmmlkom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsn6w8kt8f08fyvmmlkom.png" alt="Image description" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;create-next-app&lt;/code&gt; and enter some basic information, and your Next.js project will be set up.&lt;/p&gt;

&lt;p&gt;Next, navigate into the project directory and run &lt;code&gt;npm run dev&lt;/code&gt; to start the development server:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkfxj0mce1hvpmcfsrmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkfxj0mce1hvpmcfsrmt.png" alt="Image description" width="614" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you can see the page in your browser, that means it’s running successfully:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73q1yytx80774pwij3by.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73q1yytx80774pwij3by.png" alt="Image description" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the project directory, you'll find an &lt;code&gt;app&lt;/code&gt; folder under &lt;code&gt;src&lt;/code&gt;, which contains a &lt;code&gt;page.tsx&lt;/code&gt; file:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjf3wdeh307wn7md80h0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjf3wdeh307wn7md80h0.png" alt="Image description" width="628" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add a few directories:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlahbgwxldt0rjtbp98y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlahbgwxldt0rjtbp98y.png" alt="Image description" width="670" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;/nextjser/handsome/page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Handsome&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;handsome&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;/nextjser/nice/page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Nice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;nice&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then visit the following link in browser:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpg2sqmizc2q1mbh0l7ko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpg2sqmizc2q1mbh0l7ko.png" alt="Image description" width="626" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxtah5es1mcxd618jfzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxtah5es1mcxd618jfzg.png" alt="Image description" width="549" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that by adding a few directories, several corresponding routes are automatically created.&lt;/p&gt;

&lt;p&gt;This is Next.js's file system-based routing.&lt;/p&gt;

&lt;p&gt;Having just learned that &lt;code&gt;page.tsx&lt;/code&gt; is used to define pages, what if multiple pages have common parts?&lt;/p&gt;

&lt;p&gt;For example, what about menus and navigation like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntvk33q4t7yr5adv7ynt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntvk33q4t7yr5adv7ynt.png" alt="Image description" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Definitely not one copy per page.&lt;/p&gt;

&lt;p&gt;This kind of definition goes inside &lt;code&gt;layout.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;app/layout.tsx&lt;/code&gt; is for defining the outermost layout:&lt;/p&gt;

&lt;p&gt;That is, the HTML structure, as well as information like title and description:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5gm0qyg6eba958vrydq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5gm0qyg6eba958vrydq.png" alt="Image description" width="800" height="671"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see these in the HTML source code of the web page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0loo0qltv6z7vdls5lz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0loo0qltv6z7vdls5lz.png" alt="Image description" width="363" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkb8wo2069yczba8qss4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkb8wo2069yczba8qss4a.png" alt="Image description" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not only can the root route define a layout, but every level can as well:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpdh8po6rfpzvqzz84xi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpdh8po6rfpzvqzz84xi.png" alt="Image description" width="593" height="227"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nb"&gt;Readonly&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Left menu&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;    
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next.js will automatically wrap the &lt;code&gt;page.tsx&lt;/code&gt; components with the &lt;code&gt;layout.tsx&lt;/code&gt; components on the outer layer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bbc2k09eyhzfgdsr7bv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bbc2k09eyhzfgdsr7bv.png" alt="Image description" width="411" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some friends might notice a gradient background, which is defined in &lt;code&gt;global.css&lt;/code&gt;. Let's remove it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r4b6whm7a7jq3se95j7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r4b6whm7a7jq3se95j7.png" alt="Image description" width="364" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3xhq9o3ux62ojmy0rfo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3xhq9o3ux62ojmy0rfo.png" alt="Image description" width="431" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then continue to look at:&lt;/p&gt;

&lt;p&gt;We can use the Link component to navigate between different routes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft4d3ot3ob9f6vhwwx98x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft4d3ot3ob9f6vhwwx98x.png" alt="Image description" width="698" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06caop5bdzl93nomkj06.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06caop5bdzl93nomkj06.gif" alt="Image description" width="420" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dynamic Routes
&lt;/h2&gt;

&lt;p&gt;Some friends might say, "This is all quite normal."&lt;/p&gt;

&lt;p&gt;So let's look at something not so normal next:&lt;/p&gt;

&lt;p&gt;If I want to define a page for a route like &lt;code&gt;/dong/111/xxx/222&lt;/code&gt; (where &lt;code&gt;111&lt;/code&gt; and &lt;code&gt;222&lt;/code&gt; are parameters in the path), how should I write it?&lt;/p&gt;

&lt;p&gt;You could like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyeq0589qugyon7rnorn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyeq0589qugyon7rnorn.png" alt="Image description" width="759" height="269"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Params&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;param1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;param2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Xxx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Params&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;xxx&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;params：&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parameters in the path are named using the [xxx] notation.&lt;/p&gt;

&lt;p&gt;Next.js will extract the parameters from the path and pass them into the component:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flz1lvvsj0brrtkxvvc07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flz1lvvsj0brrtkxvvc07.png" alt="Image description" width="421" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is called a dynamic route.&lt;/p&gt;

&lt;h4&gt;
  
  
  Catch-all Segments
&lt;/h4&gt;

&lt;p&gt;What if you want both &lt;code&gt;/dong2/a/b/c&lt;/code&gt; and &lt;code&gt;/dong2/a/d/e&lt;/code&gt; to render the same component?&lt;/p&gt;

&lt;p&gt;You can code it like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lp8un7xulrdowazjpix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lp8un7xulrdowazjpix.png" alt="Image description" width="773" height="246"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Params&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;dong&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Dong2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Params&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;dong2&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;params：&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The syntax [...slug] is used to define routes with arbitrary depth, known as catch-all routes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmcctzecrvbp9v379cla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmcctzecrvbp9v379cla.png" alt="Image description" width="356" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqz7xsb6njn5u0xifd5q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqz7xsb6njn5u0xifd5q9.png" alt="Image description" width="372" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that any route under &lt;code&gt;/dong2&lt;/code&gt; will render this component.&lt;/p&gt;

&lt;h4&gt;
  
  
  Optional Catch-all Segments
&lt;/h4&gt;

&lt;p&gt;What if I directly access &lt;code&gt;/dong2&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcdcob6nymfb3unceu2ua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcdcob6nymfb3unceu2ua.png" alt="Image description" width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that it results in a 404 error.&lt;/p&gt;

&lt;p&gt;But this can also be supported; just add another set of brackets to make it &lt;code&gt;[[...slug]]&lt;/code&gt;, and it will work:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yjw49cxjlybc7mddid8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yjw49cxjlybc7mddid8.png" alt="Image description" width="329" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this change, &lt;code&gt;/dong2&lt;/code&gt; will also render this component, although the parameters will be empty.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4b1j3eeltnm2su00nl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4b1j3eeltnm2su00nl5.png" alt="Image description" width="448" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This type of route, [[...dong]], is called an optional catch-all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Route Groups
&lt;/h2&gt;

&lt;p&gt;You can see that the directories in a Next.js project are not just simple directories; they have corresponding routing implications.&lt;/p&gt;

&lt;p&gt;But what if I just want to add a plain directory that is not included in the routing?&lt;/p&gt;

&lt;p&gt;You can write it like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqk12ua93winqtpov7pv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqk12ua93winqtpov7pv.png" alt="Image description" width="332" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I added a directory called "(dongGroup)" outside of both dong and dong2; will the previous routes change?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtd9i9dfgigfgq280f6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtd9i9dfgigfgq280f6h.png" alt="Image description" width="500" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I tried it, and it remains unchanged.&lt;/p&gt;

&lt;p&gt;This means that as long as you add a () around the directory name, it won't be included in the routing; it's just for grouping purposes, which is called a routing group.&lt;/p&gt;

&lt;p&gt;Now, we have rendered a single page under one layout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallel Routes
&lt;/h2&gt;

&lt;p&gt;But what if I want one layout to render multiple pages?&lt;/p&gt;

&lt;p&gt;You can write it like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2pta7wriv86kxux6xqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2pta7wriv86kxux6xqt.png" alt="Image description" width="708" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under the &lt;code&gt;parallel&lt;/code&gt; directory, there are 3 pages: &lt;code&gt;page.tsx&lt;/code&gt;, &lt;code&gt;@aaa/page.tsx&lt;/code&gt;, and &lt;code&gt;@bbb/page.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They will be passed into &lt;code&gt;layout.tsx&lt;/code&gt; with the parameters &lt;code&gt;children&lt;/code&gt;, &lt;code&gt;aaa&lt;/code&gt;, and &lt;code&gt;bbb&lt;/code&gt;, respectively.&lt;/p&gt;

&lt;p&gt;layouts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;aaa&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;bbb&lt;/span&gt;
&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;aaa&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;bbb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;aaa&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;bbb&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;page&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/aaa"&gt;@aaa&lt;/a&gt;/page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Aaa&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;aaa&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/bbb"&gt;@bbb&lt;/a&gt;/page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Bbb&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;bbb&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rendering will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hezk8e9og2cmri3yzgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hezk8e9og2cmri3yzgv.png" alt="Image description" width="547" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that in the layout, the contents of 3 pages are included, all rendered out. This is called parallel routing.&lt;/p&gt;

&lt;p&gt;Some friends might ask, can I access &lt;code&gt;/parallel/@aaa&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbys4e7sig2reorlbnnya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbys4e7sig2reorlbnnya.png" alt="Image description" width="532" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No, it is not possible.&lt;/p&gt;

&lt;p&gt;Additionally, Next.js has a very powerful routing mechanism:&lt;/p&gt;

&lt;h2&gt;
  
  
  Intercepting Routes
&lt;/h2&gt;

&lt;p&gt;There was such a route before:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhvc0systgw5bmtzs0tm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhvc0systgw5bmtzs0tm.png" alt="Image description" width="702" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We define a route at the same level as it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmulec464hdfoqdghtyvr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmulec464hdfoqdghtyvr.png" alt="Image description" width="800" height="236"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;next/link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Go&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/nextjser/liu"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;to nice&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;go&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clicking the link will take you to &lt;a href="http://localhost:3000/nextjser/nice" rel="noopener noreferrer"&gt;http://localhost:3000/nextjser/nice&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ecc93br7mp89lzs79my.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ecc93br7mp89lzs79my.gif" alt="Image description" width="660" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's no problem with that.&lt;/p&gt;

&lt;p&gt;But what if I add a directory named &lt;code&gt;(..)nice&lt;/code&gt; under &lt;code&gt;go&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcvurf6k8l0ta7qhjx3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcvurf6k8l0ta7qhjx3s.png" alt="Image description" width="797" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, try it again:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm4pb024s3glp1jok3jq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm4pb024s3glp1jok3jq.gif" alt="Image description" width="578" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that this time the rendered &lt;code&gt;nice&lt;/code&gt; component has been replaced, but if you refresh, it's still the previous component.&lt;/p&gt;

&lt;p&gt;Many people might wonder, what's the use of this?&lt;/p&gt;

&lt;p&gt;A scenario example will make it clear.&lt;/p&gt;

&lt;p&gt;For instance, with a table, when you click on each item, an edit dialog pops up. This edit page can be shared, and when the shared link is opened, it shows the complete edit page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fowmrsvb3tzo80o1ssirt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fowmrsvb3tzo80o1ssirt.png" alt="Image description" width="724" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is to say, in different scenarios, you can override the component rendered by this URL, which is the use of route interception.&lt;/p&gt;

&lt;p&gt;The usage is also very simple. Since you want to intercept the &lt;code&gt;/nextjser/nice&lt;/code&gt; route at the upper level, you need to add &lt;code&gt;(..)&lt;/code&gt; in front.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdm4xjypdse65g7qz7pj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdm4xjypdse65g7qz7pj.png" alt="Image description" width="319" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, &lt;code&gt;(.)xx&lt;/code&gt; represents intercepting the route of the current directory, &lt;code&gt;(..)(..)xx&lt;/code&gt; intercepts the route of the parent's parent directory, and &lt;code&gt;(...)xxx&lt;/code&gt; intercepts the root route.&lt;/p&gt;

&lt;p&gt;This kind of route interception is very useful in specific scenarios.&lt;/p&gt;

&lt;p&gt;These are the routing mechanisms related to pages, which are quite powerful, aren't they?&lt;/p&gt;

&lt;h2&gt;
  
  
  APIs
&lt;/h2&gt;

&lt;p&gt;Of course, these routing mechanisms are not only for pages; Next.js can also be used to define APIs such as Get and Post.&lt;/p&gt;

&lt;p&gt;Just replace &lt;code&gt;page.tsx&lt;/code&gt; with &lt;code&gt;route.ts&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqmlde408jwhsz0tysno.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqmlde408jwhsz0tysno.png" alt="Image description" width="696" height="333"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;guang&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dong&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;searchParams&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have defined the GET method for the &lt;code&gt;/guang3&lt;/code&gt; route, which retrieves data based on the &lt;code&gt;id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's visit it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01uey61wgbtw1f3xokgg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01uey61wgbtw1f3xokgg.png" alt="Image description" width="690" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qp9s213hrk7yh3fciq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qp9s213hrk7yh3fciq8.png" alt="Image description" width="696" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The routing concepts we learned earlier can all be applied to &lt;code&gt;route.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvkbbkgapa5tjjv9bse8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvkbbkgapa5tjjv9bse8.png" alt="Image description" width="694" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[id]&lt;/code&gt; defines a dynamic route parameter, and &lt;code&gt;[...yyy]&lt;/code&gt; matches arbitrary routes.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;GET&lt;/code&gt; method of &lt;code&gt;route.ts&lt;/code&gt;, you also retrieve them through &lt;code&gt;params&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Params&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;yyy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;yyy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;yyy&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqs1fixini10kfhig3f6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqs1fixini10kfhig3f6.png" alt="Image description" width="692" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  App router &amp;amp; Page router
&lt;/h2&gt;

&lt;p&gt;Do you feel why Next.js is called a full-stack framework rather than just an SSR (Server-Side Rendering) framework?&lt;/p&gt;

&lt;p&gt;This is because, in addition to rendering React components, it can also define APIs.&lt;/p&gt;

&lt;p&gt;In this way, we have gone through the routing mechanism of Next.js.&lt;/p&gt;

&lt;p&gt;This kind of routing mechanism is called the app router, which means the top level is the &lt;code&gt;app&lt;/code&gt; directory:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fek379243he9jn2iohkyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fek379243he9jn2iohkyg.png" alt="Image description" width="311" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Previously, there was also a &lt;code&gt;page router&lt;/code&gt;, where the top-level directory was &lt;code&gt;pages&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;These two are just two different file and directory naming conventions; we only need to learn &lt;code&gt;app router&lt;/code&gt;, as it is the latest routing mechanism.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Let's summarize what we've learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;aaa/bbb/page.tsx&lt;/code&gt; can define the route for &lt;code&gt;/aaa/bbb&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aaa/[id]/bbb/[id2]/page.tsx&lt;/code&gt; contains &lt;code&gt;[id]&lt;/code&gt; as dynamic route parameters, which can be accessed within the component.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aaa/[...xxx]/page.tsx&lt;/code&gt; can match any route like &lt;code&gt;/aaa/xxx/xxx/xxx&lt;/code&gt;, called a catch-all dynamic route. However, it does not match &lt;code&gt;/aaa&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aaa/[[...xxx]]/page.tsx&lt;/code&gt; is similar to the above but matches &lt;code&gt;/aaa&lt;/code&gt; as well, called an optional catch-all dynamic route.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aaa/(xxx)/bbb/page.tsx&lt;/code&gt; where &lt;code&gt;(xxx)&lt;/code&gt; is just for grouping and does not participate in routing, called a routing group.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aaa/@xxx/page.tsx&lt;/code&gt; can be included multiple times in &lt;code&gt;layout.tsx&lt;/code&gt;, called parallel routing.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aaa/(..)/bbb/page.js&lt;/code&gt; can intercept the &lt;code&gt;/bbb&lt;/code&gt; route, rewrite the corresponding component, but after refreshing, it still renders the original component, called an intercepting route.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These routing mechanisms may indeed seem quite peculiar, and they can make a Next.js project look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6fky952i7za133y4et9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6fky952i7za133y4et9.png" alt="Image description" width="321" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Compared to this file system-based routing, many might be more familiar with the programmatic routing style of React Router:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkc1vcc2plufiqngj8rc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkc1vcc2plufiqngj8rc.png" alt="Image description" width="733" height="818"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next.js's declarative routing is actually quite convenient once you get used to it.&lt;/p&gt;

&lt;p&gt;There's no need to maintain separate routing logic; the directory structure itself defines the routes, making it clear at a glance.&lt;/p&gt;

&lt;p&gt;Moreover, these seemingly strange syntaxes actually make sense when you think about them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For example, &lt;code&gt;[xxx]&lt;/code&gt; is a common syntax for matching parameters in a URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[...xxx]&lt;/code&gt; simply adds &lt;code&gt;...&lt;/code&gt; to it, which in JavaScript signifies an arbitrary number of arguments, so it's used to match routes with arbitrary segments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adding another set of brackets &lt;code&gt;[[...xxx]]&lt;/code&gt; indicates that the route can be optional, which is also a natural design choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;(.)xx&lt;/code&gt; and &lt;code&gt;(..)xxx&lt;/code&gt; use &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt;, which are symbols in file systems, making them quite natural for intercepting routes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Routing groups are denoted by parentheses &lt;code&gt;(xxx)&lt;/code&gt; to indicate grouping, and parallel routes are indicated by &lt;code&gt;@&lt;/code&gt; in &lt;code&gt;@xxx&lt;/code&gt; to show that multiple pages can be included, all of which are intuitive designs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, Next.js's implementation of this routing mechanism based on the file system, with these seemingly strange syntaxes, are actually quite reasonable designs.&lt;/p&gt;

&lt;p&gt;We've learned about Next.js's routing mechanism, which is defined based on the file system for interfaces or page routes.&lt;/p&gt;

&lt;p&gt;Next.js's routing mechanism is quite powerful, supporting many features, These syntaxes may seem a bit odd at first glance, but upon closer consideration, they are quite reasonable designs.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>How to understand the concepts of Next.js such as CSR , SSR, SSG, ISR, RSC, SPA, and Streaming SSR?</title>
      <dc:creator>Nextjser</dc:creator>
      <pubDate>Fri, 30 Aug 2024 10:20:54 +0000</pubDate>
      <link>https://dev.to/nextjser/how-to-understand-the-concepts-of-nextjs-such-as-csr-ssr-ssg-isr-rsc-spa-and-streaming-ssr-pl3</link>
      <guid>https://dev.to/nextjser/how-to-understand-the-concepts-of-nextjs-such-as-csr-ssr-ssg-isr-rsc-spa-and-streaming-ssr-pl3</guid>
      <description>&lt;p&gt;In this article, we explain the concepts of CSR, SSR, SSG, ISR, RSC, SPA, Streaming, and Navigation in the context of a Next.js project, helping you gain a clear understanding of Next.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  SPA
&lt;/h2&gt;

&lt;p&gt;Let's kick things off with something we're all familiar with: SPAs. According to MDN, here's the lowdown on SPAs:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;An SPA (Single-page application) is a web app implementation that loads only a single web document, and then updates the body content of that single document via JavaScript APIs such as &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" rel="noopener noreferrer"&gt;Fetch&lt;/a&gt; when different content is to be shown.&lt;br&gt;
This therefore allows users to use websites without loading whole new pages from the server, which can result in performance gains and a more dynamic experience, with some tradeoff disadvantages such as SEO, more effort required to maintain state, implement navigation, and do meaningful performance monitoring.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So here's the question: Are projects created with frameworks like Next.js or SvelteKit considered SPA? Let's take a look at a Next.js project to find out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmssrfxvjhga47gtcwl2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmssrfxvjhga47gtcwl2.gif" alt="Nextjs website"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the official website of Next.js. When you click on a link, the page doesn't refresh, but the main content does get updated, and the route address changes. So, is this kind of project a SPA?&lt;/p&gt;

&lt;p&gt;It's hard to say and can be controversial.&lt;/p&gt;

&lt;p&gt;If you go by MDN's definition of "loading a single web page and then updating the main content with JavaScript," then it's considered a SPA. But usually, people think of SPAs as having pure client-side rendering and not updating the URL when the content updates (which is why SPAs have SEO issues).&lt;/p&gt;

&lt;p&gt;However, Next.js projects both update the URL and use SSR, which makes up for the SEO issues that SPAs have. In fact, neither the Next.js nor the Svelte official websites use the term SPA directly when introducing themselves; instead, they use words like "Navigating" to describe content updates through JavaScript.&lt;/p&gt;

&lt;p&gt;So, it both is and isn't. When it is, the term &lt;strong&gt;traditional SPA&lt;/strong&gt; is also used to make a distinction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Navigation
&lt;/h2&gt;

&lt;p&gt;How is an SPA implemented? That brings us to the concept of Navigation, which is essentially the process of moving from one URL to another.&lt;/p&gt;

&lt;p&gt;In the case of the Next.js official website, Navigation primarily refers to client-side navigation. This is where JavaScript intercepts the link clicks, fetches the address of the target route, and then updates the route accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSR
&lt;/h2&gt;

&lt;p&gt;CSR, which stands for "Client-side Rendering". As the name suggests, the rendering work is mainly carried out on the client side.&lt;/p&gt;

&lt;p&gt;The traditional way we use React is an example of client-side rendering. The browser first downloads a minimal HTML file along with the necessary JavaScript files. Within the JavaScript, operations such as sending requests, fetching data, updating the DOM, and rendering the page are executed.&lt;/p&gt;

&lt;p&gt;There are mainly two issues with CSR:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Performance issues, as rendering on the client side is subject to the client's environment, such as internet speed and device performance. The page will not be fully rendered until the JavaScript is downloaded, parsed, executed, and the data requests are returned.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SEO issues, although modern crawlers are generally capable of supporting pages rendered with CSR, the level of support varies.&lt;/p&gt;
&lt;h2&gt;
  
  
  SSR
&lt;/h2&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;SSR, which stands for "Server-side Rendering," is a method where the rendering of web pages is done primarily on the server. Here's a translation of the provided text into conversational English:&lt;/p&gt;

&lt;p&gt;SSR, short for "Server-side Rendering," is all about doing the heavy lifting of rendering on the server side. Imagine loading a blog post page; instead of making the client handle the request every time, which might be slow due to their internet connection, the server can take the initiative. It can directly fetch the data from the API, render it into a static HTML file, and then send that back to the user.&lt;/p&gt;

&lt;p&gt;Even though it's still making a request, the server typically has a more robust environment in terms of network and hardware, which usually results in faster rendering times, especially for the first screen load.&lt;/p&gt;

&lt;p&gt;While the overall speed is often faster, SSR might take longer to respond compared to CSR. This is because SSR has to request the data, render the HTML, and then send it back. In terms of performance metrics, specifically TTFB (Time To First Byte), SSR takes more time. That's why in development, you can't just throw all the APIs into SSR; doing so could actually make things slower.&lt;/p&gt;

&lt;p&gt;On the plus side, SSR is great for SEO. It solves many of the SEO issues that can come up with client-side rendering.&lt;/p&gt;

&lt;h2&gt;
  
  
  SSG
&lt;/h2&gt;

&lt;p&gt;SSG, which stands for "Static Site Generation". Compiles pages into static HTML files during the build phase. &lt;/p&gt;

&lt;p&gt;For example, when opening a blog post page, since the content displayed to everyone is the same, there's no need for the server to make a request to an API every time a user requests the page. Instead, the data can be fetched beforehand and compiled into an HTML file in advance. When the user visits the page, the HTML file is served directly, resulting in faster loading speeds. Additionally, pairing this with CDN caching can make it even faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  ISR
&lt;/h2&gt;

&lt;p&gt;ISR, which stands for "Incremental Static Regeneration". Imagine you're opening a blog post page: the main content might stay the same, but things like likes and bookmarks are always changing. With SSG, once the HTML file is generated, these dynamic data points can't be updated accurately, so you might end up switching to SSR or CSR.&lt;/p&gt;

&lt;p&gt;To address this, Next.js introduced ISR. When someone visits the page, they see the old HTML content at first. Meanwhile, Next.js generates a new static HTML file in the background. The next time you or another user visits the page, it’ll show the updated content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Streaming SSR
&lt;/h2&gt;

&lt;p&gt;Traditional SSR, while solving SEO issues, still has a lot of problems. First, SSR needs to fully render the page on the server before sending it to the client. Second, to keep the server and client component trees consistent, all the component code has to be bundled into the client-side package. Lastly, once hydration starts, the entire process is blocking, meaning the user can’t interact with the page until hydration is fully complete.&lt;/p&gt;

&lt;p&gt;To address these issues, Streaming SSR, or what’s commonly known as "streaming rendering," was introduced. Next.js uses HTTP's chunked transfer encoding to implement this. With chunked transfer encoding, data is sent in a series of chunks from the server to the client, allowing the page to be progressively rendered as it’s received.&lt;/p&gt;

&lt;p&gt;In simple terms, the server keeps sending content to the browser, and the browser renders it as it comes in. React uses the Suspense component to make this work. Suspense cleverly uses a placeholder while the data is loading, and once the data is ready, it streams the real content into the HTML, replacing the placeholder and allowing for progressive rendering.&lt;/p&gt;

&lt;p&gt;This approach solves two main issues:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Components don’t have to be fully rendered on the server before being sent to the client—they can be streamed progressively, which improves the user experience.&lt;/li&gt;
&lt;li&gt;Selective hydration: the page can be hydrated in parts, and even prioritize hydration based on user interactions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, it doesn’t completely solve all the problems. The client still has to download all the component code and hydrate everything, even if some components only need static rendering and don’t require any client-side interaction, which wastes performance. The current ultimate solution to this is React Server Components (RSC).&lt;/p&gt;

&lt;h2&gt;
  
  
  RSC
&lt;/h2&gt;

&lt;p&gt;RSC, which stands for "React Server Component," introduces a new way to think about rendering pages. Previously, concepts like SSR (Server-Side Rendering), CSR (Client-Side Rendering), SSG (Static Site Generation), and ISR (Incremental Static Regeneration) applied to entire pages, meaning the whole page had to be rendered using one method. But let’s rethink how we want to render a page.&lt;/p&gt;

&lt;p&gt;Take a blog post page, for example. It has purely static parts, like the article content, and interactive parts, like the like and bookmark buttons. If we break it down by components, we can define the static parts as server components. Why server components? Because they render faster on the server, are SEO-friendly, and produce HTML + CSS, which is perfect for static content.&lt;/p&gt;

&lt;p&gt;On the other hand, the interactive parts are client components because they require client-side interaction, meaning they need browser DOM events. This requires hydration (the process of adding event handlers) on the client side after rendering.&lt;/p&gt;

&lt;p&gt;Since server and client components are handled differently, they need to be distinguished. Client components are marked with a &lt;code&gt;use client&lt;/code&gt; directive. Once you break down a page into multiple server and client components, it becomes difficult to label the entire page as SSR or CSR. This is why, after Next.js 13 introduced the App Router, the official documentation de-emphasized these terms. If you still want to think in those terms, you could simplify it by saying that server components are SSR and client components are CSR.&lt;/p&gt;

&lt;p&gt;Now that the components are split, how do we render the page? Server components are straightforward—they’re rendered on the server as HTML + CSS. Client components also go through an SSR process initially because they might return some content, but they’re marked as client components (a process some refer to as "marking holes"). The libraries and code dependencies for server components stay on the server, while the client components’ dependencies are bundled and sent to the client, where hydration and rendering take place.&lt;/p&gt;

&lt;p&gt;In simple terms, all components initially go through SSR. The client components are marked, and the output is HTML + CSS, while the client components’ dependencies are bundled into JS. Both the HTML and JS are sent to the client, where the JS runs and hydrates the client components, adding the necessary interactive events, thus completing the initial page rendering.&lt;/p&gt;

&lt;p&gt;I believe RSC solves two major problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Bundle Size Reduction:&lt;/strong&gt; By splitting components into server and client components, server components are rendered on the server, and the client only needs the final rendering result. This means the server component dependencies don’t need to be bundled into the client JS, reducing the size of the client bundle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Selective Rendering and Hydration:&lt;/strong&gt; In traditional SSR, all component code had to be downloaded to the client for hydration. But with RSC, since components are clearly differentiated, only the client components need hydration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When navigating to a new page, instead of fetching data on the client side like in traditional CSR, RSC handles the rendering on the server. Directly replacing the current HTML with the target route’s HTML would break the page’s state, so RSC uses a custom format called RSC Payload. This payload includes the rendered result of the server components, placeholders for client components, references to files, and the data passed from server components to client components. The client then uses this payload for partial rendering and updates, allowing the state to be maintained.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;RSC doesn't conflict with SSR or Streaming; it's actually a blend of these technologies in Next.js. For instance, all components, whether client or server, are rendered on the server, and the HTML is streamed to the client. During navigation, the RSC Payload is optimized for streaming too. RSC and SSR complement each other, working together to boost app performance.&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
