Rivil
ERP
See all of ERPLive formsBookings, careers, reviews: the forms we put on your site, ready to try.
Request a demo
CRM
See all of CRMSee an exampleWhat cost per lead and ROAS look like by campaign.
Request a demo
eCommerce
View page eCommerceSee the demo storeA real store on the ERP API: cart, wishlist, checkout and account.
Request a demo
Websites
View page WebsitesSee demo sitesA cabin, an event organiser and a corporate site, with bookings, tickets and jobs.
Request a demo
AI
View page AIHow you stay in controlAgents propose, you approve. Cost in view, versions to go back to, and a stop button.
Request a demo
Who it’s for
All industriesLet Rivi check your businessRivi, the R from our logo, asks a few questions and tells you what would help.
Request a demo
Other solutions
Custom solutionsThe Rivil ecosystemAll our apps and services in one map, and how to build something with us.
Request a demo
Resources
All toolsAll guides
Request a demo
Pricing
Get a quote for your needsPick the modules you want and we send you a clear offer.
Request a demo
Log in

No account yet? Free accounts: Rivil Consent, Rivil QR

Request a demo

site-kit: the Astro client for the Rivil site API

Build the site. The data comes from the ERP.

@rivil-solutions/site-kit talks to the Rivil site API (/api/site/v1) from your server. Use it on an Astro site, or on any Node server, built on top of Rivil ERP. The site key never reaches the browser.

npm i @rivil-solutions/site-kit

Also: npx degit iorpaul3/rivil-site-template my-site

import { createContentApi, createSiteClient } from '@rivil-solutions/site-kit'

export const rivil = createSiteClient({ url: process.env.ERP_URL!, key: process.env.ERP_SITE_KEY! })
export const content = createContentApi(rivil)

const menus = await content.menus('en')
const page = await content.one('page', 'about', 'en')
What’s inside

What’s inside the package

The package is the client for the Site API, plus the pieces a site needs around it: cache, webhooks, modules, shop, languages and SEO. It updates with npm update, so a fix reaches every site that uses it.

createSiteClient

Requests with the site key. Reads are cached in memory (fresh for 60 seconds, then served stale and refreshed in the background), identical requests are merged, and purge() refreshes everything after a webhook. Errors come as RivilApiError (status, code, message).

createContentApi

The Site module: settings, menus, redirects, terms, entries, search, forms.

createModulesApi

Public reads of booking, careers, reviews and events, for server-rendered pages.

siteProxy

The browser calls /api/rivil/... on the site; the site calls the ERP with the key. Only visitor actions get through (MODULE_ROUTES).

@rivil-solutions/site-kit/web

What also runs in the browser: rivilFetch, SiteError, money, days, consents, bookingPlan.

@rivil-solutions/site-kit/react

Form logic for the modules, with no styling: useBooking, useStay, useApplication, useReview, useEventCheckout. Peer dependency: React 18 or newer.

Webhooks

rivilWebhookHandler and verifyRivilSignature for signed webhooks (X-Rivil-Signature).

Visitor IP

visitorIp plus the X-Rivil-Client-IP header, so ERP rate limits apply per visitor, not per site.

createI18n

Language from the URL prefix (/en/...), t(), lp(), translated segments, prefixed internal links.

Images

imageAt, imageWidths and @rivil-solutions/site-kit/astro-image: Gallery images at the right width, with no processing on the server.

SEO helpers

sitemapXml, robotsTxt, matchRedirect: sitemap, robots and the redirects set in the ERP.

Consent

consentScriptUrl for the Rivil Consent banner.

createShopApi

Catalog, cart, shipping, checkout, customer account, gift cards and returns, with the language in the URL. warmProducts() loads the catalog into memory at startup; purgeChanged handles the shop.changed webhook.

accountProxy

The customer account (portal) through the site, session in an httpOnly cookie, only the allowed routes (AUTH_ROUTES).

rivil CLI

Copies module pages and starting themes into a site.

Start with an AI assistant

Paste one prompt and run the site locally

After the trial is ready, the handover page gives you a prompt for Claude or Cursor. It installs the starter, writes .env with your keys and runs npm run dev.

1

Install Node.js 20+

If it is missing, the prompt tells you what to install.

2

Copy the handover prompt

One text block with keys and commands, not in email.

3

Change a title in the ERP

See it on localhost in a few minutes.

How it works

The browser talks to the site, the site talks to the ERP

Visitor actions never go to the ERP with the site key in the browser. Pages are rendered on the server. When something must be submitted from the browser (a booking, a form, an account request), the request hits a route on the site; the site adds the key and calls the ERP. Only the visitor actions allowed by the package get through.

Visitor browser

Pages arrive already rendered

  • /api/rivil/... (siteProxy, visitor actions only)
  • /api/account/... (accountProxy, httpOnly session cookie)

Your Astro or Node site

The keys stay here

  • ERP_SITE_KEY, SHOP_CHANNEL_KEY, ERP_PORTAL_KEY
  • createContentApi, createModulesApi, createShopApi

Rivil ERP

Content, modules and shop

  • /api/site/v1 and the shop API
  • Signed webhook: X-Rivil-Signature

/api/hooks/rivil on the siterivil.purge() or shop.purgeChanged(...)

The site key never leaves the server. Rate limits use the visitor’s IP (X-Rivil-Client-IP), not the site’s.

What not to touch

  • The site key is server only: never in the browser or in PUBLIC_*.
  • Do not rewrite the webhook route or the /api/rivil route.
  • Do not put texts, prices, opening hours or phone numbers in code when they already live in the ERP.
// src/pages/api/rivil/[...path].ts
import { siteProxy } from '@rivil-solutions/site-kit'
import { client, siteUrl } from '../../../lib/rivil'

// origins: behind a reverse proxy, Astro sees the request on localhost
const proxy = siteProxy({ client, origins: [siteUrl()] })
export const ALL = (c) => proxy({ request: c.request, path: c.params.path, clientAddress: c.clientAddress })
Modules and themes

Add booking, jobs, events and more with one command

rivil add copies the module’s pages and styled components into the site. From then on they belong to the site and can be changed freely. The logic (free slots, holds, validation, submitting) stays in this package and is updated with it.

The command also prints the scopes the site key needs and the English URL segments to add to site.config.ts.

npx rivil list
npx rivil add booking events
npx rivil theme cabana

booking

Online booking: services, specialist, time, confirmation

stay

Stays: free rooms by night, reservation

careers

Open jobs, job page, application with CV

reviews

Published reviews and the review form

events

Events, paid tickets, the order

newsletter

Newsletter signup, with email confirmation

Starting themes

The starting themes come from the demo sites and only change colors and fonts.

aercabanacurtelumenmiezsolvar

The shop is not a module to copy

Start from Casa Lumen, which uses the same package, and use createShopApi with a shop channel key.

Shop and account

Shop and customer account

The shop uses the same package, with a channel key. createShopApi covers the catalog, cart, shipping, checkout, customer account, gift cards and returns. At startup, call warmProducts() once per language. When the ERP sends shop.changed, call shop.purgeChanged(event.data.object) so only what changed is refreshed.

The customer account (portal) goes through the site: accountProxy plus AUTH_ROUTES, a session in an httpOnly cookie, and only the allowed routes. Use a portal key (ERP_PORTAL_KEY in the README sample), separate from the site key.

import { createShopApi, createSiteClient } from '@rivil-solutions/site-kit'

const client = createSiteClient({ url: process.env.ERP_URL!, key: process.env.SHOP_CHANNEL_KEY!, visitorIp: () => ipStore.getStore() })
export const shop = createShopApi(client, { lang: () => i18n.lang() })

// at startup, once per language: await shop.warmProducts()
// shop.changed webhook: shop.purgeChanged(event.data.object)
// src/pages/api/account/[...path].ts
import { AUTH_ROUTES, accountProxy, createSiteClient } from '@rivil-solutions/site-kit'

const proxy = accountProxy({
  client: createSiteClient({ url: process.env.ERP_URL!, key: process.env.ERP_PORTAL_KEY! }),
  cookie: 'site_session',
  routes: [...AUTH_ROUTES, { method: 'GET', path: /^me$/, session: true }, { method: 'PATCH', path: /^me$/, session: true, changes: true }],
})
export const ALL = (c) => proxy({ request: c.request, path: c.params.path, cookies: c.cookies, clientAddress: c.clientAddress })
Webhooks and cache

A webhook clears the cache when something changes

Reads through createSiteClient stay fresh for 60 seconds, then can be served stale while they refresh in the background. Identical in-flight requests are merged. After a signed webhook, purge() refreshes everything. For the shop, purgeChanged can limit the refresh to what the shop.changed event names.

Set the webhook in the ERP, on the site, to /api/hooks/rivil, with the content.* events (and shop.changed when you run a store). The handler verifies X-Rivil-Signature with ERP_WEBHOOK_SECRET.

// src/pages/api/hooks/rivil.ts
import { rivilWebhookHandler } from '@rivil-solutions/site-kit'
import { rivil } from '../../../lib/rivil'

export const POST = ({ request }) => rivilWebhookHandler(process.env.ERP_WEBHOOK_SECRET!, (e) => {
  if (e.type.startsWith('content.')) rivil.purge()
})(request)
Languages, images, SEO

Languages, images and SEO, from the ERP

createI18n reads the language from the URL prefix (/en/...), and gives you t(), lp(), translated segments and prefixed internal links. In the starter, the first locale has no prefix and the others do. Menus, redirects, titles and the sitemap come from the ERP; the package helps you emit sitemapXml, robotsTxt and apply matchRedirect.

Gallery images are resized by width with imageAt and imageWidths, and in Astro you can set the image service to @rivil-solutions/site-kit/astro-image, with no image processing on your server. consentScriptUrl loads the Rivil Consent banner.

// astro.config.mjs
export default defineConfig({ image: { service: { entrypoint: '@rivil-solutions/site-kit/astro-image' } } })
Starter template

Start from the Astro starter

rivil-site-template is an Astro site that takes its content from the Rivil Site module: home page, pages and posts following the URL pattern set in Site, menus, contact form, 404, sitemap, robots, and a second language on /en. It also includes rules for Claude Code and Cursor (AGENTS.md). To let the assistant see types, fields and entries in the ERP, set RIVIL_API_KEY (an API key with access to Site only) and use the included .mcp.json and .cursor/mcp.json.

  1. 1

    Get the code

    Use the template on GitHub, or npx degit iorpaul3/rivil-site-template my-site.

  2. 2

    Set up the site in the ERP

    Under Site: create the site, then on its page a site key and, so it updates by itself, a webhook to /api/hooks/rivil with the content.* events.

  3. 3

    Fill in .env

    Copy .env.example to .env and fill in ERP_URL and ERP_SITE_KEY (and ERP_WEBHOOK_SECRET for the webhook).

  4. 4

    Run it

    npm install, then npm run dev: the site shows the company’s real data on http://localhost:4321.

  5. 5

    Deploy once

    Work locally until it looks right, then deploy once (Dockerfile included). On the server, set the same variables, plus SITE_INDEX=true on the final domain only.

The package and the starter are MIT licensed.

Starter on GitHubFull starter guideDocs for AI assistantsDemo sites

Questions

What people ask us

Do I have to use Astro?

The package is written for Astro sites, or any Node server, on top of Rivil ERP. The public starter and the rivil add and rivil theme commands copy Astro pages and components. There are also React hooks (@rivil-solutions/site-kit/react) and a browser module (@rivil-solutions/site-kit/web). If you are not on Astro, you can still use the client on a Node server; you will wire the routes yourself.

Does the site key reach the browser?

No. The client runs on the server. The site key must never go into the browser or into a PUBLIC_* variable. The browser calls /api/rivil/... (and /api/account/... for the customer account) on your site; your site calls the ERP with the key.

What does npx rivil add change in my project?

It copies the module’s pages and styled components into the site. Those files are yours to change. The logic (free slots, holds, validation, submitting) stays in @rivil-solutions/site-kit and is updated with the package. The command also prints the scopes the site key needs and the English URL segments to add to site.config.ts.

Can I add the shop the same way?

No. The shop is not a module to copy with rivil add. You start from Casa Lumen, which uses the same package, and you use createShopApi with a shop channel key. There is a live demo store at demo-ecommerce.rivil.app.

How does the site stay in sync with the ERP?

Reads are cached in memory: fresh for 60 seconds, then served stale and refreshed in the background. You set a signed webhook on the site to /api/hooks/rivil (for example content.*, and shop.changed for the store). The handler calls purge() or shop.purgeChanged(...).

Can I build this with Cursor or Claude?

Yes. The starter ships AGENTS.md and MCP config for Cursor and Claude. Set RIVIL_API_KEY to a key with access to Site only, so the assistant can see types, fields and entries. The docs also have a page for AI assistants, plus prompts. You still need a Rivil site and a site key; request access if you do not have them yet.

Get a site key and start

You need a Rivil site and a site key. Tell us what you want to build; we can give you access, a test environment, and the starter. The docs and the package are public.

Popular pages