⚠️ 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

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.