⚠️ This lesson is retired and might contain outdated information.

Create Pages in Blitz.js

Khaled Garbaya
InstructorKhaled Garbaya
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 2 years ago

In Blitz, a page is a React Component exported from a .js, .jsx, .ts, or .tsx file in a pages directory. Each page is associated with a route based on its file name.

Example: if you create a file under app/pages/post like below, it will be accessible at /about

const Post = () => {
  return (
    <div>
      <h1>Hello World</h1>
    </div>
  )
}

export default Post

Unlike Next.js, you can have many pages/ folders nested inside app/. This way pages can be organized neatly, especially for larger projects.

Khaled Garbaya: [0:00] To add a new page to our Blitz app, let's go to pages folder, create a new file, call it about.tsx. In here, let's paste in some code. Hit Save. Now, when we go to our app and go to /about, we can see here our page created.

[0:25] You can also have nested pages inside of the pages folder, so let's create a new folder, call it posts. Inside of that, let's create a new file, call it post1.tsx. Let's take this code and call this post. Hit Save and go to our URL. Instead of about, let's do posts/post1. You can see here our page is displayed.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today