GitHub

Self Hosted

How to self host a jsrepo registry.

jsrepo enables self hosting your registry on the web. This can allow for more customization of exactly how things are served. As well as enabling you to do things like distributing your registry on a private network.

Let's show how you might set this up in a SvelteKit app!

In this case we will have our block located under ./src/lib where components is the category and button is one of our blocks:

root ├── .svelte-kit ├── src │ └── lib │ └── components │ └── button ├── static ├── .gitignore ├── .npmrc ├── package.json ├── svelte.config.js ├── tsconfig.json └── vite.config.ts

We will serve our registry out of the ./static folder (for react this would be ./public) so that users can access our blocks by running:

npx jsrepo add --repo https://example.com/

To do this we need to build the registry using the --output-dir flag. This flag will copy the registry to whatever directory we specify in this case ./static:

npx jsrepo build --output-dir ./static

You can also customize where blocks are served. You just need to tell jsrepo where the jsrepo-manifest.json is.

root ├── ... ├── static │ ├── default │ │ ├── ... │ │ └── jsrepo-manifest.json │ └── new-york │ ├── ... │ └── jsrepo-manifest.json └── ...

Now users can access blocks from either https://example.com/default or https://example.com/new-york:

npx jsrepo add --repo https://example.com/default

You can still add fully qualified blocks but as always the path must be complete:

npx jsrepo add --repo https://example.com/default/ui/accordion