Skip to content

How to load local image in Next JS 14 ? #1403

Discussion options

You must be logged in to vote

We have a section in the docs for the CLI on this. Take a look at https://react.email/docs/cli#where-can-i-place-my-static-files-for-previewing

In the case of NextJS you will need to have your assets both in your public folder, and in your email/static, and then you should have something like, in the case of hosting on Vercel:

const baseUrl = process.env.VERCEL_URL
  ? `https://${process.env.VERCEL_URL}`
  : "";

export default function Email(props) {
  return (
    <div>
      <img src={`${baseURL}/static/email-logo.png`} />
    </div>
  )
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@cotwitch
Comment options

@gabrielmfern
Comment options

Answer selected by gabrielmfern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants