Next.js 13.3 发布,添加多个新功能

1,226次阅读
没有评论

Next.js 13.3 近日正式发布,新版本添加了多个社区用户要求的受欢迎的功能,并会在下一个次要版本中将 App Router 标记为稳定,Next.js 13.3 具体更新内容包括:

基于文件的 Metadata API

在 Next.js 13.2 中,Next.js 公布了一个新的 Metadata API,允许用户通过从布局或页面导出 Metadata 对象来定义元数据(例如 HTML head元素中的 titlemetalink标签)。

// layout.js or page.js

// either Static metadata
export const metadata = {
title: ‘Home’,
};
// Output:
// <head>
// <title>Home</title>
// </head>

// or Dynamic metadata
export async function generateMetadata({ params, searchParams }) {
const product = await getProduct(params.id);
return { title: product.title };
}
// Output:
// <head>
// <title>My Unique Product</title>
// </head>

export default function Page() {}

除了基于配置的元数据外,Metadata API 现在还支持新的文件约定,开发者可以方便地自定义页面以改进 SEO 和在 Web 上共享:

  • opengraph-image.(jpg|png|svg)
  • twitter-image.(jpg|png|svg)
  • favicon.ico
  • icon.(ico|jpg|png|svg)
  • sitemap.(xml|js|jsx|ts|tsx)
  • robots.(txt|js|jsx|ts|tsx)
  • manifest.(json|js|jsx|ts|tsx)

动态 OG 图像生成

六个月前,Next.js 发布了 @vercel/ogSatori 库,它们允许您使用 JSX、HTML 和 CSS 动态生成图像。

自发布以来,随着 Vercel 客户的广泛采用和超过 900,000 次下载,Next.js 很高兴能够将动态生成的图像引入所有 Next.js 应用程序,而无需外部包。

现在可以从 next/server导入 ImageResponse生成图像:

// /app/about/opengraph-image.tsx
import { ImageResponse } from 'next/server';

export const size = { width: 1200, height: 600 };
export const alt = ‘About Acme’;
export const contentType = ‘image/png’;

export default function og() {
return new ImageResponse();
// …
}

App Router 的静态导出

Next.js App Router 现在完全支持静态导出。开发者可以从静态网站或单页应用程序(SPA)开始,然后再选择性地升级,以使用需要服务器的Next.js功能。

在运行 next build 时,Next.js会在每个路由中生成一个HTML文件。通过将严格的SPA分解成单独的HTML文件,Next.js可以避免在客户端加载不必要的JavaScript代码,减少包的大小,实现更快的页面加载。

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
};

module.exports = nextConfig;

并行路由和拦截

Next.js 13.3 引入了新的动态约定,允许开发者实现高级路由案例: 并行路由和拦截路由。这些功能使你能够在同一个视图中显示一个以上的页面,比如复杂的仪表盘等。

通过并行路由,你可以在同一个视图中同时呈现一个或多个可以独立浏览的页面。它还可以用来有条件地渲染页面。

并行路由是使用命名的 “slots” 创建的。Slots 是用 @folder 约定进行定义的。

拦截路由允许您在当前布局中加载新路由,同时 “屏蔽” 浏览器 URL。 当保持当前页面的上下文很重要时,这很有用。

拦截路由可以使用 (..) 约定进行定义,类似于相对路径 ../. 开发者还可以使用 (...) 约定创建相对于 app 目录的路径。

其他

  • Next.js 主页和展示页面已经更新了新的设计
  • next.config.js 的快速刷新
  • 针对 create-next-app 的 Tailwind CSS
  • 改进的样式表加载
  • ……

更多详情可查看:https://github.com/vercel/next.js/releases/tag/v13.3.0

Read More 

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2023 年 4 月
 12
3456789
10111213141516
17181920212223
24252627282930
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026 Jay 2025-12-22 09...
面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25

面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25

面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25 鹭羽 2025-12-13 22:37...
商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1

商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1

商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1 十三 2025-12-15 14:13:14 ...
跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026 一水 2025-1...
10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了 一水 2025-12-12 13:56:19 ...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026 一水 2025-1...
10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了 一水 2025-12-12 13:56:19 ...
IDC MarketScape: 容联云位居“中国AI赋能的联络中心”领导者类别

IDC MarketScape: 容联云位居“中国AI赋能的联络中心”领导者类别

IDC MarketScape: 容联云位居“中国AI赋能的联络中心”领导者类别 量子位的朋友们 2025-1...