AWS S3 バケットから翻訳を取得し、それらをコンテキストに配置して、1 つのページだけでなくアプリケーション全体で使用できるようにしたいと考えています。この翻訳データはどこで取得しますか? app.js では or を使用できず、使用することgetStaticProps
はgetServerSideProps
推奨されていませんgetInitialProps
(ドキュメンテーションがあまり明確ではないため、とにかく使用するのが混乱しています)。Web で以下のスニペットを見ましたが、どこで使用するかわかりません探しているプロップを取得し、 getInitialProps のエンドポイントをどこでフェッチする必要がありますか:
import React from 'react'
import App from 'next/app'
import { appWithTranslation } from '../i18n'
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
MyApp.getInitialProps = async (appContext) => {
const appProps = await App.getInitialProps(appContext)
// shall I fetch my data here and provide the prop as
// const xx = fetch('url')?
return { ...appProps, xx }
}
export default appWithTranslation(MyApp)
_app.js で使用すると、自動静的生成をオプトアウトしますか? どういう意味ですか?app.js で getInitialProps を使用すると、クライアント側のコードを使用できなくなりますか?