Full Stack Development

Introduction to Next.js

by Tomas Trescak t.trescak@westernsydney.edu.au

Next.js

/

Creating an Empty Project

    pnpx create-next-app@latest
  
    import Component from "../../../components/Component"; // <- Not this
import Component from "@/components/Component" // <- This
  
    import Component from "~/components/Component"; // <- This
import Component from "@/components/Component" // <- or, this
import Component from "$/components/Component" // <- or, this ...
  
    $ cd my-test-project
$ code .
  

Next.js

/

Folder Structure

    /my-next-app
├── /app
│   ├── /layout.tsx
│   ├── /page.tsx
│   ├── /dashboard
│   │   ├── /page.tsx
│   │   ├── /settings
│   │   │   ├── /page.tsx
│   ├── /api
│   │   ├── /route.ts
├── /components
├── /lib
├── /public
├── /styles
├── /utils
├── /node_modules
├── .gitignore
├── next.config.js
├── package.json
├── tsconfig.json
  

Next.js

/

Running the Project

    pnpm run
pnpm build
pnpm start
  

Next.js

/

Our Project