# Scrt.link is built for developers.

I previously wrote about [why I created scrt.link](https://blog.stophe.com/why-i-created-scrtlink) - now here is a follow-up especially for developers who might be interested in the project. scrt.link was always open source, but it has been structured in a way that made it hard understand what's going on behind the scenes (one big repo). As a first step towards better (code) accessibility I extracted core functionalities into a developer friendly npm package. Not only can everybody better understand how this product works, it also **allows developers to use this service programmatically** within their own projects.

For context, sharing information in a truly secure way is harder than you'd think. You can only guarantee confidentiality with **end-to-end encryption**. In other words, the information you want to transmit has to be encrypted and decrypted **on the client**. This means you can't just create a secure server infrastructure and offer a public API - you also need code executed on the client. The good news is, you can now just do that.

[scrt-link-core](https://www.npmjs.com/package/scrt-link-core) has just been published.  Use it in your project. It's free.

## Installation
In any node based environment you can just install the package like this:
```bash
yarn add scrt-link-core
# or: npm i scrt-link-core

```

## Basic usage
The heart of the package is the `createSecret` function that handles the encryption of the secret, as well as the communication with the API. It returns an object containing `secretLink`.  (This package assumes that you use scrt.link as your backend, but it's not mandatory - feel free to create your own backend. See [scrt-link](https://gitlab.com/kingchiller/scrt-link) for reference code.)
```
import { createSecret } from "scrt-link-core";

const { secretLink } = await createSecret("Some confidential information…");
// https://scrt.link/l#hLN8e0jd6xtLuxJqDxp1D/Q4rqaOWQtzFTZIB-7TXEYD2NgI9E1KQdeMXdfsvPykI
```


### Via (hosted) ES Modules

**Now wait** - before you think it's too much trouble - you don't even need to install any package. With e.g. [Skypack](https://skypack.dev/) it's possible to literally create a secret link with just two lines of code - wherever you need it. Just drop the following snipped into your HTML:


```js
<script type="module">
  import { createSecret } from "https://cdn.skypack.dev/scrt-link-core";

  createSecret("Some confidential information…").then(({ secretLink }) => {console.log(secretLink)});
// https://scrt.link/l#hLN8e0jd6xtLuxJqDxp1D/Q4rqaOWQtzFTZIB-7TXEYD2NgI9E1KQdeMXdfsvPykI
</script>
```


For more information and examples read the [full documentation](https://www.npmjs.com/package/scrt-link-core).


All code is open source and on [Gitlab](https://gitlab.com/kingchiller/scrt-link-core).


Feedback is very welcome :)

