Publishing to Dev.to from Strapi with the Forem API
Dev.to runs on Forem, and Forem has a simple REST API for creating articles. This post shows how a Strapi plugin can send a post there.
Get an API key
In your Dev.to settings, open Extensions and generate a key. Store it in an environment variable, never in the plugin code.
Send the article
Make a POST request to https://dev.to/api/articles with an api-key header. The body holds title, body_markdown, published and canonical_url.
await fetch('https://dev.to/api/articles', {
method: 'POST',
headers: { 'api-key': key, 'Content-Type': 'application/json' },
body: JSON.stringify({ article: { title, body_markdown, published: true } }),
});
Save the result
The response holds the article url. Save it next to the Strapi entry so editors can see where the post went.
Wrapping up
Start small, ship it, and improve it as you learn what your readers need.
Top comments (0)