NextWeb.js

NextWeb.js

  • Docs
  • GitHub

›Getting Started

Getting Started

  • Getting Started
  • Folder Structure
  • Create a New Page
  • Navigate Between Pages

App

  • Environment Variables
  • Module Alias
  • Routing
  • Context
  • Store
  • Authentication

Page

  • Layout
  • Meta
  • Breadcrumb
  • Stats
  • Restricted Pages

Data Fetching

  • Repositories & Services
  • Server-Side Fetching
  • Client-Side Fetching
  • Error Handling
  • Custom Error

Styling

  • Local Styles
  • Global Styles
  • Grids
  • Style Helpers
  • Fonts
  • Icons

Deployment

  • Deployment

Create a New Page

First, create a new react component to represent your page. In this case, we will create a very simple page called My Page.

// src/components/mypage/index.js

import React from 'react'
import withPage from '@lib/page/withPage'

function MyPage() {
  return <div>My Page</div>
}

export default withPage()(MyPage)

Note: Please remember that every react components should be placed inside src/components directory.

Did you see a higher-order component called withPage() ? Is it required ? Yes, because it will make your component becomes a page in NextWeb.js.

After you created your page component, you have to register it to Next.js. Just create a new file in src/pages add put the following code:

// src/pages/mypage.js

import MyPage from '@components/mypage'
export default MyPage

You will see that this file do nothing but import your page component and then export it as a Next.js compatible page.

← Folder StructureNavigate Between Pages →