Laravel OG Kit
Dynamic OG images for Laravel, designed in your own HTML and CSS.
composer require mischasigtermans/laravel-ogkit
A static OG image says the same thing for every page you share. Making it dynamic usually means an image pipeline: a headless browser on a server, or text drawn on a canvas in code. OG Kit skips that. You design the image as HTML and CSS, OG Kit screenshots it at 1200x630, and the screenshot URL becomes your og:image.
This package is the Laravel side of it. A Blade component, three directives, a service you can call from a controller or a Livewire component, and a set of templates to start from. Stagent uses it in production.
It is not the renderer. OG Kit is a hosted service by Peter Suhm, so the package needs an OG Kit API key as OGKIT_API_KEY in your .env.
The templates use Tailwind. Add the package's views to your Tailwind content paths and import its CSS utilities, or the classes won't make it into your build.
What it does
-
From a controller or from Blade
Set a template with $ogkit->template() in a controller or Livewire component, or put an <x-ogkit-template> component in a view. @ogkit in your head outputs the og: and twitter: meta tags.
-
Templates to start from
Blog posts, product pages with prices, author cards, docs and repositories. Each takes its own fields, such as title, image, price or readingTime.
-
Or your own HTML
Write a custom template in Blade with Tailwind classes, colour props and og- utility classes. Pick any Google Font, a secondary font, and a background pattern or gradient.
-
Preview before you share
Set OGKIT_PREVIEW=true and every HTML response gets an OG Preview button that shows exactly what will be screenshotted.
-
A version for cache busting
The @ogkitUrl directive and $ogkit->imageUrl() take a version, so a changed design can get a fresh image URL.
Hi, I'm Mischa. I've been shipping products and building ventures for over a decade. First exit at 25, second at 30. Now Partner & CPO at Ryde Ventures, an AI venture studio in Amsterdam. Currently shipping Stagent, TAP and Steddle. I write about what I learn along the way. More about me.
You might also enjoy: Nightshift: why Friday's gig is on Saturday.