DEV Community

Add a "Share to DEV" Button to Your Site

The Share to DEV button works exactly like Twitter and Facebook share buttons. It opens a page with pre-filled content that you can specify.

A Twitter share link might look like this:

https://twitter.com/intent/tweet?text=%22Announcing%20off-platform%20%22Share%20to%20DEV%22%20functionality%22%20by%20@bendhalpern%20%23DEVcommunity%20https://dev.to/devteam/announcing-off-platform-share-to-dev-functionality-57j9

The tweet link accepts text, links, etc. via parameters.

Share to DEV accepts arbitrary markdown using the prefill parameter in the same way that the tweet link accepts text (or url depending on which way you use the Twitter guidelines). Markdown gives flexibility to define the default content a user can use to compose a DEV post in terms of title, tags, embeds, etc.

https://dev.to/new?prefill=---%0Atitle%3A%20Wow,%20Share%20to%20DEV%20is%20really%20cool!%0Apublished%3A%20true%0Atags%3Ameta%0A---%0A%0ANice%20stuff%20DEV%20Team!%0A%0A%7B%25%20link%20devteam%2Fannouncing-off-platform-share-to-dev-functionality-57j9%20%25%7D

You must encode the markdown in the URL as shown above.

It is up to you to decide whether this link should open up in a new tab, a pop-up window, etc. Pop-up windows are a common pattern, but not necessary. You will most likely be extending the functionality you already use for Twitter links, etc.

Share to DEV buttons pair well with liquid tags which is the custom syntax DEV uses to embed content such as GitHub issues, CodePens, Replits, etc. If we are missing a liquid tag, feel free to create an issue or a pull request to help get something implemented.

This integration can already be found on code sites like CodePen and Repl.it, and are a great way to integrate with our growing community!

How it looks on CodePen:

If a user is not logged in, they will see a log-in page specific to this prompt.

The Share to DEV prefilled link is a simple, flexible integration. You may want to check out our API guide for more information about how to interact programmatically with our community.