Now with Next.js 14, we want to simplify the developer experience of authoring data mutations. Further, we want to improve the user experience when the user has a slow network connection, or when submitting a form from a lower-powered device.
14では開発体験を簡単にしようとしてて、将来的にはユーザー体験も良くしたいって考えてるらしい👀
API dir
import type { NextApiRequest, NextApiResponse } from 'next';
export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
const data = req.body;
const id = await createItem(data);
res.status(200).json({ id });
}
import { FormEvent } from 'react';
export default function Page() {
async function onSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
const formData = new FormData(event.currentTarget);
const response = await fetch('/api/submit', {
method: 'POST',
body: formData,
});
// Handle response if necessary
const data = await response.json();
// ...
}
return (
<form onSubmit={onSubmit}>
<input type="text" name="name" />
<button type="submit">Submit</button>
</form>
);
}
Not API dir
export default function Page() {
async function create(formData: FormData) {
'use server';
const id = await createItem(formData);
}
return (
<form action={create}>
<input type="text" name="name" />
<button type="submit">Submit</button>
</form>
);
}
Our challenge was to create a better developer experience, simplifying the existing model without introducing new APIs for developers to learn. While partial caching of server-side content has existed, these approaches still need to meet the developer experience and composability goals we aim for.
新たに勉強しなくっても使えるようにっていう配慮、素敵だね。
開発中だから、でき次第お知らせしてくれるみたい。でも、ブログには必要なさそう📝
末尾の記述が関連してきそうな予感だけど、、、、今は大丈夫かな(ヒヤヒヤ
https://nextjs.org/blog/next-14#other-changes
yarn add next@latest react@latest react-dom@latest eslint-config-next@latest
https://nextjs.org/blog/next-14#other-changes
• Minimum Node.js version is now 18.17
brew install nvm
mkdir ~/.nvm
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm' >> ~/.zshrc
source ~/.zshrc
nvm install 18.17.0
nvm use 18.17.0
nvm use ***
で指定すればいいbrew install nvm
だけやるnpx browserslist@latest --update-db
punycode
モジュール警告の原因調査
"scripts": {
"dev": "next dev",
+ "dev:trace": "NODE_OPTIONS='--trace-deprecation' next dev",
"start": "next start",
一時的にtraceを入れてyarn dev:trace
を実行すると、めっちゃ出る 🥶
出処は、notionhq/client
yarn upgrade @notionhq/client@latest
詳細:
images: {
domains: [
's3.us-west-2.amazonaws.com',
'images.unsplash.com',
'cdn.buymeacoffee.com',
],
},
この、domainsの部分を変更する。
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 's3.us-west-2.amazonaws.com',
},
{
protocol: 'https',
hostname: 'images.unsplash.com',
},
{
protocol: 'https',
hostname: 'cdn.buymeacoffee.com',
},
],
**** あと同じ *****
画像少ないDWBブログではこの警告はなかったけど、herohoroブログでは出てたから対処DONE(/・ω・)/
deployのエラーは….
まだ調整が必要👀
詳細:
next/server
からじゃなくってnext/og
からにする
import { ImageResponse } from 'next/og';
これでOK\(^o^)/