The pages are placed inside the app folder. The page file must be written us page.js/page.jsx
For dynamic pages, you can use square bracket => [slug]
To group pages, you can use parenthesis => (auth)
The children in the layout.js represents pages layout of the app or website.
In addition, it is possible to create a layout.js for each page, in its folder
The components should be placed inside the src folder. Each file should have its folder and the file must be start with capital letter as react. For instance, Navbar.jsx
create loading.jsx file in the app folder that could be used for all pages.
It is also possible to create a loading.jsx file for each page
create error.jsx file in the app folder that could be used for all pages.
It is also possible to create a error.jsx file for each page
Add the "use client" directive on the top of the file to resolve the
Got to next.config.mjs file. and then add this code => images: { remotePatterns: [ { protocol: 'https', hostname: "cdn.britannica.com" } ] }
hostname represents the domain
Search engine optimization could be done using the layout.js file, specifically metadata.
Hence, to optimize the search engine, you need to handle the title and description values using the keywords.
This metadata applies to each and every page of the project
When you are in the server side, you need to include;
- "use server"
- async for the function
- Please open the link https://authjs.dev/getting-started website
- Open API References
- Select next-auth
- open next-auth documentation
- npm install next-auth@beta
- AUTH_SECRET and AUTH_URL have to be included in the .env file
- create auth.js file under the database folder called lib folder
- then import
- import NextAuth from "next-auth"
- import GitHub from "next-auth/providers/github"
- export const { handlers, auth } = NextAuth({ providers: [ GitHub ] })
- fs
To generate random password, you need to run openssl rand -base64 32 in the terminal
- openssl rand -base64 32
- open github account
- Click on settings
- Click on Developer settings
- Click on OAuth Apps
- Click on Register a new application
- Give Application name (e.g. next14 portfolio)
- Homepage URL (e.g. http:https://localhost:3000)
- Authorization callback URL (e.g. http:https://localhost:3000/api/auth/callback/github)
- Click on Register Application
- Store the Client ID and Client secrets in env file
Open the react documentation website using this linek: https://react.dev/learn
got to useFormStatus
useFormStatus is a Hook that gives you status information of the last form submission.
const { pending, data, method, action } = useFormStatus();