Skip to content

Commit a0b174a

Browse files
committed
Video 133 Completed
1 parent cee0761 commit a0b174a

File tree

15 files changed

+5468
-0
lines changed

15 files changed

+5468
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

Video 133/ssr-ssg-isr/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

Video 133/ssr-ssg-isr/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
22+
23+
## SSR - Server Side Rendering
24+
This is default behaviour
25+
26+
## SSG - Static Site Generation
27+
Any content which does not have network calls is a static page by default
28+
29+
## ISG or ISR
30+
fetch in next.js caches the response
31+
To opt out use:
32+
```
33+
export const dynamic = 'force-dynamic';
34+
```
35+
However, there are exceptions, fetch requests are not cached when:
36+
37+
- Used inside a Server Action.
38+
- Used inside a Route Handler that uses the POST method.
39+
40+
25.3 KB
Binary file not shown.
66.3 KB
Binary file not shown.
64.7 KB
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
:root {
6+
--background: #ffffff;
7+
--foreground: #171717;
8+
}
9+
10+
@media (prefers-color-scheme: dark) {
11+
:root {
12+
--background: #0a0a0a;
13+
--foreground: #ededed;
14+
}
15+
}
16+
17+
body {
18+
color: var(--foreground);
19+
background: var(--background);
20+
font-family: Arial, Helvetica, sans-serif;
21+
}
22+
23+
@layer utilities {
24+
.text-balance {
25+
text-wrap: balance;
26+
}
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import localFont from "next/font/local";
2+
import "./globals.css";
3+
4+
const geistSans = localFont({
5+
src: "./fonts/GeistVF.woff",
6+
variable: "--font-geist-sans",
7+
weight: "100 900",
8+
});
9+
const geistMono = localFont({
10+
src: "./fonts/GeistMonoVF.woff",
11+
variable: "--font-geist-mono",
12+
weight: "100 900",
13+
});
14+
15+
export const metadata = {
16+
title: "Create Next App",
17+
description: "Generated by create next app",
18+
};
19+
20+
export default function RootLayout({ children }) {
21+
return (
22+
<html lang="en">
23+
<body
24+
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
25+
>
26+
{children}
27+
</body>
28+
</html>
29+
);
30+
}

Video 133/ssr-ssg-isr/app/page.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Image from "next/image";
2+
3+
export default async function Home() {
4+
5+
let data = await fetch('https://api.vercel.app/blog', { next: { revalidate: 3600 } })
6+
let posts = await data.json()
7+
return (
8+
<ul>
9+
{posts.map((post) => (
10+
<li key={post.id}>{post.title}</li>
11+
))}
12+
</ul>
13+
)
14+
}
15+
16+
// export const dynamic = 'force-dynamic'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"paths": {
4+
"@/*": ["./*"]
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)