Social Media Cards with @vercel/og

This page summarizes the projects mentioned and recommended in the original post on dev.to

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • node-canvas

    Node canvas is a Cairo backed Canvas implementation for NodeJS.

  • Another approach is it to create a background image and insert the texts and the metadata with a canvas library like node-canvas. This approach is very well described in this Learn With Jason episode. But with a canvas library we have to specify on which coordinates we want to render our texts and it does not wrap automatically if it becomes to long.

  • website

    Home of SCM-Manager (by scm-manager)

  • If all these solutions have problems with wrapping texts or require us to build the image with an external tool, why could we just use HTML+CSS to define our image? This is possible! We can create our card with HTML+SVG+CSS, open a browser and create a screenshot of the result. I've used this approach in the past and it worked well. The problem is that the process is very slow. This example creates the cards during the build. Creating the cards during the build requires external caching, because it slows down the build extremely. Also generating cards with this approach in a serverless function is often not possible, because it requires a browser within the function which breaks the size limit of those functions.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • satori

    Enlightened library to convert HTML and CSS to SVG

  • @vercel/og promises a new way of generating social media cards, which does not have the downsides of the other approaches. The library uses Satori under the hood. Satori describes itself as follows:

  • go-unsplash

    Go Client for the Unsplash API

  • After I worked my way around the size limitation of the edge function, the deployment was successful but the og endpoint responded with an error 500. The error in the vercel log did not help at all. So I started to look at the code and began to comment out parts of the code. Fortunately it didn't take very long to find out that the image of the post was the problem. It looked like there is another size limitation. The image was loaded from Unsplash and about 7mb in size. Luckily Unsplash has an api to resize the image, so we can fetch the image in exactly the size we need.

  • opentype.js

    Read and write OpenType fonts using JavaScript.

  • With an SVG we can define our image as code, which is pretty neat. But SVG is not able to wrap texts. We can use opentype.js to calculate the width of our texts and to wrap it manually. Finally we have to convert the SVG to a PNG, because the most of social media platforms do not support SVG. This approach could work, but requires a lot of code and it is very complicated.

  • opengraph

    A python module to parse the Open Graph Protocol

  • We use og tags which are accepted by most of the social media sites. Except Twitter where I've had strange results if I only used og tags. So I've added the Twitter tags besides the og tags.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • How to Create an Audio Visualizer using Nextjs

    2 projects | dev.to | 14 Apr 2024
  • Boost Your Medium Visibility: 12 Essential Tips for Writers

    1 project | dev.to | 31 Mar 2024
  • Get Random Images API for free from Lorem Picsum

    1 project | dev.to | 27 Mar 2024
  • Now Anyone Can Add Beautiful Interactive Images in ChatGPT ⏱️ (in 30 Seconds)

    1 project | dev.to | 22 Mar 2024
  • Building a flat-file CMS with Angular

    3 projects | dev.to | 5 Mar 2024