-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Announcing Vercel OG #226
Comments
Looks incredible! Are there plans to open source it? |
Well I wanted to implement this in my current project and I think after spending a few hours trying I can leave my feedback here. TLDR; too many limitations and complications, doesn't worth the trouble
As a conclusion, NextJS team is great at coming up with game-breaking features but limiting their use to Vercel-hosted deployments just ruins it all. Extra: no one asked but I would still come up with my own solution proposal. Just add new function to export const getOpenGraphImageProps: GetOpenGraphImageProps = (context): GetOpenGraphImagePropsResult => {
return {
width: 1200,
height: 630,
},;
}; |
You could change the locale based on query params rather than using the file system (note that
The goal isn't to work with any component library – I would recommend using normal CSS 👍
If you would prefer not to use Wasm, you can use
Thanks for the feedback, we will work on expanding support.
|
This is ace work, and seems super powerful. I've just spent a few hours implementing it for privacyshortlist.com, but I'm currently deploying with Netlify, is it a requirement to use Vercel hosting for this to work, or is it possible to use other providers with this package? I'm not expecting you to help debug my issue, more just working out whether it's worth debugging or if it'll require switching to Vercel to use. Cheers! |
Hey! This is a Vercel-specific product, yeah. The open-source Happy to help you move over to Vercel, lmk! |
Ace thanks @leerob, will look into the possibility of migrating over, cheers. |
Hey @nomercy360 could you reproduce it in the playground: https://og-playground.vercel.app? You can open an issue in https://github.com/vercel/satori and we will take a look! |
Thanks for the awesome lib! Great work, as always ❤️ Just wanted to report that all of the source links for the examples on |
@with-heart could you elaborate? My code works perfectly locally but is rendering a blank image when deployed, no error logs on Vercel. And when I checked on @vercel/examples, all the examples were broken, as you mentioned. |
@yannglt I have the same problem, a broken image is generated, I thought I was the only one |
@AleeRojas Yeah... this feature is pretty awesome tho — I don't really understand where this bug can come from :/ |
I was only commenting on the links on npmjs.com! I was running into issues with local rendering today, with compilation timing out. Somehow I found that setting // next.config.mjs
const nextConfig = {
// …
webpack: (config, options) => {
config.experiments = {
layers: true,
}
return config
}
// …
} |
@ vercel friends: Is there a public issues-only repo for reporting |
Bugs and feedback can be reported at https://github.com/vercel/satori |
For this I thought about this workaround:
This way you should at least be able to use emotion |
native node.js support would be great while others are only aiming to use the html to image as response without bundling chromium and puppeteer due to api limits. As of now I see it for jsx and tsx only, small projects can really make use of the feature |
@leerob I believe there is an issue with the order of the default But not sure where to report this. If you're seeing this issue, you can work around it by setting the return new ImageResponse(
(
<div
style={{
width: '2000px',
height: '1000px',
backgroundColor: '#000',
color: '#fff',
overflow: 'hidden',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
{/* ... */}
</div>
),
{
width: 2000,
height: 1000,
headers: {
'content-type': 'image/png',
'cache-control': 'public, max-age=31536000, no-transform, immutable',
},
}
) |
This is exactly what I need. However, when I try to follow the getting started guide, I get: @vercel/og 0.0.21, NextJS 13.0.5, react 18.2.0, Chrome Browser. |
You need Node.js 16 or newer. See the docs here https://vercel.com/docs/concepts/functions/edge-functions/og-image-generation |
Thanks - But Node is at 16.13.0 (Unless nextjs is running a secret version of Node it's found elsewhere....) |
@leerob Which Tailwind utilities are supported? I'm getting:
import { ImageResponse } from "@vercel/og";
export const config = {
runtime: "experimental-edge",
};
export default function handler() {
return new ImageResponse(
(
<div tw="flex gap-2">
<div tw="text-2xl">Left</div>
<div>Right</div>
</div>
),
{
width: 1200,
height: 630,
}
);
} Also, it doesn't seem to respect my project's |
Im trying to display an image, it doesn't show, kinda difficult to lookup the error, why is the image not shown? /* eslint-disable @next/next/no-img-element */
import { ImageResponse } from '@vercel/og'
import { NextRequest } from 'next/server'
export const config = {
runtime: 'experimental-edge'
}
export default async function handler(req: NextRequest) {
try {
const { searchParams } = new URL(req.url)
const hasTitle = searchParams.has('title')
const title = hasTitle ? searchParams.get('title')?.slice(0) : 'Edge OG with dynamic title'
return new ImageResponse(
(
<div tw='flex items-center h-[600px] w-full py-3 px-5 bg-gray-800 text-zinc-200'>
<div tw='flex flex-col h-full w-full whitespace-pre-wrap justify-between'>
<p tw='font-bold text-3xl text-blue-500'>https://rizkicitra.dev/blog</p>
<p tw='font-extrabold text-6xl'>{title}</p>
<div tw='flex items-center'>
<img
width='44'
height='44'
tw='rounded-full'
style={{
objectFit: 'cover'
}}
src='https://ik.imagekit.io/mlnzyx/attachment/rizkimcitra.webp'
alt='Rizki M Citra'
/>
<p tw='ml-2.5 font-bold text-4xl'>Rizki M Citra</p>
</div>
</div>
<div tw='flex items-center justify-center w-1/2 h-full'>
<img src='https://ik.imagekit.io/mlnzyx/attachment/logo.png' alt='logo' width={192} height={192} />
</div>
</div>
),
{
width: 1200,
height: 600
}
)
} catch (err) {
return new Response('Failed to generate the og image', {
status: 500,
statusText: 'failed to generate the og image'
})
}
} The result: EDIT: I wa finally able to display the image after I restart the dev server |
I'm still getting errors from tailwind wait - compiling /api/v1/og (client and server)...
event - compiled successfully in 246 ms (67 modules)
`gradient-to-tr` unknown or invalid utility
`from-zinc-900/50` unknown or invalid utility
`to-zinc-700/30` unknown or invalid utility
`gradient-to-t` unknown or invalid utility
`clip-text` unknown or invalid utility
`from-zinc-100/50` unknown or invalid utility
`to-white` unknown or invalid utility
`whitespace-pre` unknown or invalid utility Oddly enough these styles work in the OG Image Playground but not in my next13 implementation |
If you have a problem that reproduces using the playground, please create an issue in the satori repo. For all other issues with |
https://vercel.com/blog/introducing-vercel-og-image-generation-fast-dynamic-social-card-images
The text was updated successfully, but these errors were encountered: