A simple, open-source pastebin web application built with PrismJS, Cloudflare Workers, and Cloudflare KV. Users can share code snippets, text, or other types of information with syntax highlighting and an easy-to-use interface.
- Syntax Highlighting: Automatically applies syntax highlighting using PrismJS.
- Fast & Scalable: Deployed with Cloudflare Workers and powered by Cloudflare KV for storage.
- Minimal UI: Simple, clean design for pasting and sharing content.
- Share Links: Generates unique, permanent URLs for each paste.
- Open Source: Fully open-source and customizable.
- PrismJS: Lightweight, extensible syntax highlighter for web code snippets.
- Cloudflare Workers: A serverless compute platform to run JavaScript code close to your users.
- Cloudflare KV: A key-value store for fast, distributed data storage.
You can try out the demo here.
To run this project locally, you'll need to have a Cloudflare account and set up Cloudflare Workers.
- Node.js (LTS version recommended)
- Wrangler (Cloudflare Workers CLI)
- Cloudflare Account
-
Clone the Repository:
git clone https://github.com/LakhindarPal/snippets.git cd snippets
-
Install Dependencies:
npm install
-
Set Up Cloudflare Workers:
-
Set up KV storage and create a KV binding in your Cloudflare Workers dashboard.
-
Add your KV namespace binding to
wrangler.toml
:kv_namespaces = [ { binding = "PASTEBIN_KV", id = "your-kv-namespace-id" } ]
-
Configure Your Environment:
Make sure the necessary environment variables are set in
wrangler.toml
or.env
(like your KV namespace ID). -
Run the Worker Locally:
wrangler dev
Visit
http://localhost:8787
in your browser to test the app locally. -
Deploy to Cloudflare:
Once you're ready to deploy, run:
wrangler publish
-
Creating a Paste:
When a user submits a new paste, the content is stored in Cloudflare KV, and a unique URL is generated for the paste. -
Viewing a Paste:
When a user visits a URL (e.g.,https://snippets.<SUB_DOMAIN>.workers.dev//a1b2c4d5
), the content is fetched from KV and displayed with PrismJS syntax highlighting. -
Editing/Deleting:
Currently, this implementation only supports creating and viewing pastes. You can easily extend it with features like editing or deleting pastes.
Contributions are welcome! Please fork the repository and submit a pull request with your changes. Here are some ways you can help:
- Report bugs or issues.
- Suggest new features or improvements.
- Improve documentation.
Please make sure your changes pass the existing tests and follow the project's code style.
This project is licensed under the MIT License - see the LICENSE file for details.
- PrismJS for syntax highlighting.
- Cloudflare Workers for serverless backend.
- Cloudflare KV for fast, distributed storage.