Builder content link
landing-page
Code stack you are integrating Builder with
NextJS
What are you trying to accomplish
I have existing next.js site and I want to create landing page built with builder.io, all other pages should work as before, without any changes.
what I did:
- created page in"/pages/landing-page.tsx"
import { builder, BuilderComponent, Builder } from '@builder.io/react'
builder.init('a990e2f6684a4892a18e785fc204107d')
const Landing = (props) => {
return (
<>
{props.content || Builder.isPreviewing ? (
<BuilderComponent content={props.content} model='/landing-page' />
) : (
<div>404 component</div>
)}
<div>footer</div>
</>
)
}
export default Landing
export const getStaticProps = async (context) => {
const content = await builder.get('Page').promise()
console.log('content :>> ', content)
return {
props: { content },
revalidate: true,
notFound: !content,
}
}
- started dev server on https:localhost:3000
I expect to see page content from builder.io but I’m seeing 404 page.
console.log('content :>> ', content) - always return undefined, looks content wasn’t fetched from builder api
What I missed?