concept home page in category node

appears as: The home page, home page
Next.js in Action

This is an excerpt from Manning's book Next.js in Action.

The home page is an important one. It’s the entry point into the application for every user. It needs to  present summary information and provide an easy means to navigate the pages of the app.

Now we’re ready to implement the home page of our application, which is found in the pages/index.js file. Recall from the previous section that there’s two elements that we need to fill in from the template page structure that we’re following in this chapter: <main> and <style>. We’ll start with the <main> content, which is divided into two <section> elements. Here’s the first section:

Listing 3.3: A content section on the home page that shows a list of the latest messages sent to the user
<section>
  <h2>Latest Messages</h2>
  <ul className="itemList">
    <li className="messageItem">
      <div>Did you see this?</div>
      <div>
        <Link href="/friends/josh">
          <a>Josh</a>
        </Link>{" "}
        <Link href="/messages/1">
          <a>2 minutes ago</a>
        </Link>
      </div>
    </li>
    <li className="messageItem">
      <div>I can't tell if it's on or not...</div>
      <div>
        <Link href="/friends/beth">
          <a>Beth</a>
        </Link>
        <Link href="/messages/2">
          <a>1 hour ago</a>
        </Link>
      </div>
    </li>
    <li className="messageItem">
      <div>You don't need it for another week?</div>
      <div>
        <Link href="/friends/ryan">
          <a>Ryan</a>
        </Link>
        <Link href="/messages/3">
          <a>3 hours ago</a>
        </Link>
      </div>
    </li>
  </ul>
</section>
Get Programming with Node.js

This is an excerpt from Manning's book Get Programming with Node.js.

  • GET—This method requests information from a server. Typically, a server responds with content that you can view back on your browser (such as by clicking a link to see the home page of a site).
  • As in the first capstone project, Express.js offers a way to define a GET route and its callback function without building out an extra module. If a request is made to the home page, Express.js catches it and allows you to respond.

    Change the get method in your index.js file to post. Restart your application, and see how your application behaves differently when you try to access the home page at http://localhost:3000. You should see a default error message from Express, telling you that there’s no GET route for /.

    The reason is that you changed the request method you’re listening for. If you make a curl POST request to the home page, you see your original response content.

    Figure 22.2. Error flash message shown on the home page