Giter VIP home page Giter VIP logo

nextjs-masterclass's Introduction

Next.js Master Class

This repo contains all the course files for the Next.js Master Class on Net Ninja Pro. There is a branch for every lesson. Select the lesson you need from the branch dropdown.

Visit Net Ninja Pro to view this course and many more.

Getting Started with the Project

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.js. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

nextjs-masterclass's People

Contributors

iamshaunjp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nextjs-masterclass's Issues

lesson: 10, suspense not working

Entire page is waiting till promise gets resolved.

Bug: maybe in nextjs version 13.4.9
Fix: upgraded to nextjs version 13.4.12 and it worked.

Lesson 11: npm run build gives an error

I had the same error in my own version, so I downloaded the files from lesson 11 fresh off of GitHub. Both return the same error when trying to build the app:

$ npm run build

[email protected] build
next build

  • info Creating an optimized production build
  • info Compiled successfully
  • info Linting and checking validity of types
  • info Collecting page data ...TypeError: fetch failed
    at node:internal/deps/undici/undici:12618:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    cause: AggregateError [ECONNREFUSED]:
    at internalConnectMultiple (node:net:1116:18)
    at afterConnectMultiple (node:net:1683:7)
    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'ECONNREFUSED',
    [errors]: [ [Error], [Error] ]
    }
    }

Build error occurred
Error: Failed to collect page data for /tickets/[id]
at C:\Users\chris\Documents\GitHub\Netninja-Next13-Masterclass\nextjs-masterclass-lesson-11\node_modules\next\dist\build\utils.js:1158:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}

AuthApiError: invalid flow state, no valid flow state found

This works fine until the sign-up step. But once I click on the confirmation link in my mail, I am redirected to a page showing "internal server error," and I get the following error:

AuthApiError: invalid flow state, no valid flow state found

I get the exact same error when I try to replicate supabase's "User Management App with NextJS" example--from Supabase Docs, so I guess this is a bug with supabase. But I haven't yet been able to find a solution in their reports and discussion pages.
(My OS is Ubuntu and my browser is Firefox.)

Lesson #41

Hi Shaun, I'm having an issue trying to import the useFormStatus.
I've pasted the exact code from this repo
`'use client'

import { experimental_useFormStatus as useFormStatus } from 'react-dom'`

but I'm getting this error in the browser :
Unhandled Runtime Error
TypeError: (0 , react_dom__WEBPACK_IMPORTED_MODULE_1__.experimental_useFormStatus) is not a function

and in the terminal :
Attempted import error: 'experimental_useFormStatus' is not exported from 'react-dom' (imported as 'useFormStatus').
Screenshot 2023-12-23 092231

Lesson 21 - 500 Internal Server Error while trying to GET non existing ticked by id

Problem
During the tests of the tickets API, while trying to simulate a 404 return, got "500 Internal Server Error" when using an invalid id.
image
image

How to simulate the problem

  1. Download the code from the Lesson 21: https://github.com/iamshaunjp/nextjs-masterclass/tree/lesson-21
  2. Install all the dependencies with npm install
  3. Run the application with npm run dev
  4. Run the Json Server with json-server --watch --port 4000 ./_data/db.json
  5. In Postman, create a new GET request for "http://localhost:3000/tickets/999" (or any other invalid id)

Lesson 32 : Unhandled Runtime Error ReferenceError: error is not defined

Error when submitting the form in order to add the first ticket.

Unhandled Runtime Error
ReferenceError: error is not defined

Source
app(dashboard)\tickets\create\CreateForm.jsx (29:18) @ error

27 |
28 | if (json.error) {

29 | console.log(error.message)
| ^
30 | }
31 | if (json.data) {
32 | router.refresh()

Protected Routes only work after refresh (Lesson 30)

One thing I noticed is that if you log out, you can still go back to the dashboard when you press the "back" button on Google Chrome. It's only when you manually change the URL that the protected route works. Here is a demo:

Create.Next.App.-.Google.Chrome.2023-09-11.19-40-51.mp4

Is there any way to fix this, to back it so when the user navigates back, it checks if they are authenticated again, and redirects them if they are not?

Lesson 6: issue with fetching ticket data

Hi,

I'm working through the masterclass and following the instructions of lesson 6 to a T, but the app was crashing when I tried to access the Ticket page.

So I changed the 'tickets' name in the db.json file to 'ticketData' just to remove any chance that wires were getting crossed, and when I access localhost:3000/ticketData through json-server, I see the data. However, when I run the app and try, I get a 404 page.
image

When I navigate to /tickets, I get an error
image

which I have spent the last few hours googling solutions (header info in the fetch call, try/catch, moving the _data dir to the public dir) - none of them worked, so I returned to the original state of the code from the lesson to post this issue.

`async function getTickets() {
const res = await fetch('http://localhost:3000/ticketData', {
next: {
revalidate: 0 // use 0 to opt out of using cache
}
})

console.log(res)
return res.json()

}

export default async function TicketList() {
const tickets = await getTickets()

return (
		<>
			{tickets.map((ticket) => (
					<div key={ticket.id} className="card my-5">
						<h3>{ticket.title}</h3>
						<p>{ticket.body.slice(0, 200)}...</p>
						<div className={`pill ${ticket.priority}`}>
							{ticket.priority} priority
						</div>
					</div>
			))}
			{tickets.length === 0 && (
					<p className="text-center">There are no open tickets, yay!</p>
			)}
		</>
)

}`

I printed the response object:

Response { [Symbol(realm)]: null, [Symbol(state)]: { aborted: false, rangeRequested: false, timingAllowPassed: true, requestIncludesCredentials: true, type: 'default', status: 404, timingInfo: { startTime: 161106.12160000205, redirectStartTime: 0, redirectEndTime: 0, postRedirectStartTime: 161106.12160000205, finalServiceWorkerStartTime: 0, finalNetworkResponseStartTime: 0, finalNetworkRequestStartTime: 0, endTime: 0, encodedBodySize: 10, decodedBodySize: 0, finalConnectionTimingInfo: null }, cacheState: '', statusText: 'Not Found', headersList: HeadersList { cookies: null, [Symbol(headers map)]: [Map], [Symbol(headers map sorted)]: null }, urlList: [ [URL] ], body: { stream: undefined, length: undefined, source: undefined } }, [Symbol(headers)]: HeadersList { cookies: null, [Symbol(headers map)]: Map(9) { 'cache-control' => [Object], 'vary' => [Object], 'x-powered-by' => [Object], 'content-type' => [Object], 'content-encoding' => [Object], 'date' => [Object], 'connection' => [Object], 'keep-alive' => [Object], 'transfer-encoding' => [Object] }, [Symbol(headers map sorted)]: null } } ⨯ SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
But at this point I am at a complete loss, since I followed the tutorial exactly and somehow broke everything. Any insight would be greatly appreciated.

500 (Internal Server Error) when "POST" new ticket

Following lesson #32, when I try to add new ticket I get this error:
"POST http://localhost:3000/api/tickets 500 (Internal Server Error)"
I think this error happens because I've added file .env.local in the root folder (with URL and ANON KEY) but never connect it to the api/tickets/route.js file. So it looks like route.js where I make POST request cannot connect with supabase and gives me the above error.
Please correct me if I'm wrong, and help me to solve this issue.
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.