2022-11-14 07:34:13 -05:00
< h1 align = "center" > < img src = "assets/share2fedi.svg" width = "520" height = "160" alt = "Share2Fedi" > < / h1 >
2020-09-23 09:08:21 -05:00
2022-11-14 07:34:13 -05:00
> Instance-agnostic share page for the Fediverse.
2020-09-23 11:39:38 -05:00
2023-08-27 17:31:43 -05:00
**[Share₂Fedi]** (pronounced ‘ share-to-fedi’ ) allows you to share stuff on
2023-08-27 18:11:45 -05:00
Mastodon, Misskey, Friendica, and other federated social networks,
2023-08-27 17:31:43 -05:00
instance-agnostic. Just type in the post text and the instance URL, and click
‘ Post!’
2021-01-30 09:12:32 -05:00
2023-03-17 08:06:30 -05:00
Or, open this page with the prefilled `text` URL parameter—it will be
automatically inserted into the text field. The same goes for the `instance` URL
parameter. This can be used to build custom share buttons for the federated
social networks:
2020-09-23 11:39:38 -05:00
```html
2023-08-27 17:31:43 -05:00
< a href = "https://s2f.kytta.dev/?text=Hello%20world!&instance=mastodon.xyz" >
2022-11-14 07:39:51 -05:00
Share on mastodon.xyz
2020-09-23 11:39:38 -05:00
< / a >
```
2023-03-17 08:06:30 -05:00
The instance URL can be saved in your `localStorage` to be automatically
appended if used later—handy!
2021-01-30 09:12:32 -05:00
2023-08-27 17:36:01 -05:00
> [!IMPORTANT]
> I know I provide [a Share₂Fedi instance](https://s2f.kytta.dev) for others to
> use, but if you want to use Share₂Fedi for your share buttons, **please
> consider self-hosting it**. Although it's free now, running my instance may
> become too expensive for me in the future.
2021-08-28 09:03:58 -05:00
## Hosting
2023-03-17 21:02:41 -05:00
### Vercel, Netlify, Cloudflare Pages
2021-08-28 09:03:58 -05:00
2023-03-17 21:02:41 -05:00
**Share₂Fedi** was designed to run on [Vercel ](https://vercel.com/ ), but you can
also run it on [Netlify ](https://www.netlify.com/ ) or
[Cloudflare Pages ](https://pages.cloudflare.com/ ). To deploy it yourself (it's
free!), you can use the following buttons:
2021-08-28 09:03:58 -05:00
2023-03-17 21:02:41 -05:00
[![Deploy to Vercel ](https://vercel.com/button )](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fkytta%2Fshare2fedi)
[![Deploy to Netlify ](https://www.netlify.com/img/deploy/button.svg )](https://app.netlify.com/start/deploy?repository=https://github.com/kytta/share2fedi)
To deploy to Cloudflare Pages, fork the repo and
[follow the instructions ](https://docs.astro.build/en/guides/deploy/cloudflare/#how-to-deploy-a-site-with-git ).
2021-08-28 09:03:58 -05:00
### Host it yourself
2022-11-14 07:39:51 -05:00
Self-hosting **Share₂Fedi** outside of Vercel requires some extra setup:
2021-08-28 09:03:58 -05:00
2023-08-27 17:31:43 -05:00
**Prerequisites:** modern Node.js (v16 or later), `pnpm` . You can host with
Deno, but Node.js is still required.
2021-08-28 09:03:58 -05:00
2023-03-17 20:25:06 -05:00
1. Install dependencies.
2021-08-28 09:03:58 -05:00
```sh
2023-03-16 09:21:16 -05:00
pnpm install
```
2023-03-17 20:25:06 -05:00
2. Build.
2023-03-16 09:21:16 -05:00
```sh
pnpm build
2021-08-28 09:03:58 -05:00
```
2023-08-27 17:31:43 -05:00
If you want to use Deno, add the `--s2f-use-deno` flag:
```sh
pnpm build --s2f-use-deno
```
2023-03-17 20:25:06 -05:00
3. Run server.
> By default, this will only listen on localhost port 3000. To enable
2023-03-19 06:39:39 -05:00
> listening on a ceratin host and/or port, set the `HOST` and `PORT`
2023-03-17 20:25:06 -05:00
> environment variables, respectively.
2021-08-28 09:03:58 -05:00
2022-03-18 06:16:21 -05:00
```sh
2023-03-17 20:25:06 -05:00
node dist/server/entry.mjs
2022-03-18 06:16:21 -05:00
```
2022-03-18 06:39:31 -05:00
2023-03-19 06:39:39 -05:00
In production, you might want to use a process manager, like
[PM2 ](https://pm2.keymetrics.io/docs/usage/quick-start/ ):
2022-03-18 06:16:21 -05:00
2021-08-28 09:03:58 -05:00
```sh
2023-03-19 06:39:39 -05:00
# Start the app, restart on file changes (except node_modules)
pm2 start dist/server/entry.mjs --name "Share2Fedi" --watch --ignore-watch="node_modules"
2021-08-28 09:03:58 -05:00
```
2022-03-17 08:04:44 -05:00
2023-03-17 20:25:06 -05:00
> More information about self-hosting an Astro website with Node:
> https://docs.astro.build/en/guides/integrations-guide/node/#standalone
2023-08-27 17:31:43 -05:00
If you've built Share₂Fedi for Deno:
```sh
deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs
```
> More information about self-hosting an Astro website with Deno:
> https://docs.astro.build/en/guides/integrations-guide/deno/#usage
2023-03-17 20:25:06 -05:00
4. Set up a reverse proxy.
2023-03-16 09:21:16 -05:00
2023-03-17 20:25:06 -05:00
Basically, you need to run a reverse proxy that would redirect all incoming
requests to `localhost:3000` . Here's how to achieve this in various HTTP
servers:
2022-03-17 08:04:44 -05:00
2022-03-17 07:58:41 -05:00
1. Apache
2022-03-17 08:04:44 -05:00
2022-03-18 06:17:16 -05:00
```apacheconf
2023-03-17 20:25:06 -05:00
ProxyPass "/" "http://localhost:3000/"
2022-03-17 08:04:44 -05:00
```
2022-03-17 07:58:41 -05:00
2. Nginx
2022-03-18 06:17:16 -05:00
```nginxconf
2023-03-17 20:25:06 -05:00
location / {
proxy_pass http://localhost:3000/;
2022-03-17 08:04:44 -05:00
}
```
2021-08-28 09:03:58 -05:00
2022-03-18 07:04:56 -05:00
3. Caddy
2022-05-17 08:30:54 -05:00
```caddy
2023-03-17 20:25:06 -05:00
reverse_proxy :3000
2022-03-18 07:04:56 -05:00
```
2023-03-19 06:39:39 -05:00
### Docker
If you _really_ have to use Docker, there is
[a good guide on building Astro apps with Docker ](https://docs.astro.build/en/recipes/docker/ ).
**I will not** provide support for Docker-based deployments in the observable
future.
2021-01-30 09:12:32 -05:00
## See also
2023-03-17 08:06:30 -05:00
**[📯 Shareon](https://shareon.js.org)** (lightweight, stylish, and ethical
share buttons) uses **Share₂Fedi** under the hood!
2020-09-23 12:59:55 -05:00
2021-05-13 07:24:32 -05:00
## Licence
2020-09-23 12:59:55 -05:00
2023-03-19 06:39:39 -05:00
© 2020– 2023 [Nikita Karamov]\
Licensed under the [GNU Affero General Public License v3.0 or later][AGPL-3.0].
2020-09-23 12:59:55 -05:00
2022-03-17 08:04:44 -05:00
---
2021-08-29 07:10:23 -05:00
2023-03-16 04:41:55 -05:00
This project is hosted on GitHub: < https: / / github . com / kytta / share2fedi . git >
2021-08-29 07:10:23 -05:00
2023-03-19 06:39:39 -05:00
[AGPL-3.0]: https://spdx.org/licenses/AGPL-3.0-or-later.html
2022-11-14 07:39:51 -05:00
[Nikita Karamov]: https://www.kytta.dev
[Share₂Fedi]: https://s2f.kytta.dev/