Getting Started with Next.js 13

1 min read
Next.js application dashboard example
A modern Next.js application interface

Test Blog Post

Just some random stuff to see if I can make a blog.

Some image from the web

The next section

This next section follow on from the first one, snazzy

1// app/page.tsx
2export default function HomePage() {
3 return (
4 <main className="p-8">
5 <h1 className="text-4xl font-bold">
6 OOoh a code snippet
7 </h1>
8 <p className="mt-4">
9 This is a server component by default!
10 </p>
11 </main>
12 );
13}

Another section!

This was all written in markdown by the way, pretty cool.

1// app/posts/page.tsx
2async function getPosts() {
3 const res = await fetch('https://api.example.com/posts');
4 return res.json();
5}
6
7export default async function PostsPage() {
8 const posts = await getPosts();
9
10 return (
11 <ul>
12 {posts.map(post => (
13 <li key={post.id}>{post.title}</li>
14 ))}
15 </ul>
16 );
17}

Data Fetching

The new data fetching system is more intuitive and powerful, allowing for better caching and revalidation strategies.