Skip to content
TypeScript
4.4 KB
Raw Blame
---
title: Vinext
description: Deploy vinext to Prisma Compute with the shared Website API, native local development, and traced runtime dependencies.
sidebar:
  order: 9.6
---

import PackageManagers from "../../../../components/PackageManagers.astro";

export const devDeps = "@alchemy.run/frontend-frameworks @vercel/nft";

`Prisma.Website.Vinext` builds with the Vinext Vite API, then hosts vinext's production
Node server on **Bun in Prisma Compute**. Alchemy packages `dist/`, public
assets, and locally installed runtime dependencies into a `tar.gz` artifact.
There is no Dockerfile, registry, Wrangler configuration, or OpenNext build.

## Install

Keep `vinext`, `react`, `react-dom`, and `react-server-dom-webpack` in your
application dependencies, and install `vite` and `@vitejs/plugin-rsc` for
building. Add the Alchemy integration and dependency tracer:

<PackageManagers dev={devDeps} />

## Configure vinext

```typescript
// vite.config.ts
import { defineConfig } from "vite";
import vinext from "vinext";

export default defineConfig({
  plugins: [vinext({ prerender: true })],
});
```

Alchemy injects the Node data-cache adapter during deployment. No Alchemy plugin
is required in `vite.config.ts`. Configure deployment settings on
`Prisma.Website.Vinext` and leave Cloudflare plugins out of the Vite config.

## Declare the Website

```typescript
// alchemy.run.ts
import * as Prisma from "@alchemy.run/prisma";

export const Website = Prisma.Website.Vinext("Website", {
  rootDir: ".",
});
```

A live deployment creates a database-less project when `project` is omitted.
Pass an existing project to share it with other applications.

## Add it to the Stack

```typescript
import * as Alchemy from "alchemy";
import * as Effect from "effect/Effect";

export default Alchemy.Stack(
  "MyVinextSite",
  { providers: Prisma.providers(), state: Alchemy.localState() },
  Effect.gen(function* () {
    const site = yield* Website;
    return { url: site.url };
  }),
);
```

`site.url` is the Compute endpoint on deploy and the native dev-server URL locally.
The result also exposes `compute`, `project`, and `domain`, matching other
Prisma Website constructors.

## Add environment variables

```typescript
export const Website = Prisma.Website.Vinext("Website", {
  env: { GREETING: "Hello from vinext on Prisma!" },
});
```

`env` is available during build, development, and production. Server components,
route handlers, and server actions read `process.env`. Public framework variables
can be compiled into browser assets; keep secrets out of public keys.

## Configure the data cache

The default cache is process-local and does not survive a Compute restart or
provide cross-instance consistency. For persistent ISR and `"use cache"`, provide
an existing Redis endpoint:

```typescript
import * as Redacted from "effect/Redacted";

export const Website = Prisma.Website.Vinext("Website", {
  env: {
    REDIS_URL: Redacted.make("rediss://user:[email protected]:6379"),
  },
});
```

The injected cache adapter uses Redis when `REDIS_URL` is set and memory
otherwise. Prisma.Website does not provision Redis. The same Node adapter is
used by Fly, Hetzner, and Railway.

## Local development

```sh
bun alchemy dev
```

The Website runs `vinext dev` with native HMR without creating a Prisma project,
Compute service, or custom domain. Other resources declared in the Stack retain
their own provider behavior. Apply `.pipe(Alchemy.remote())` to deploy the
Website to Compute during development.

## Custom domains

```typescript
const site = yield* Prisma.Website.Vinext("Web", {
  domain: "app.example.com",
});
```

Configure the returned DNS records
and verify domain status before routing traffic; see
[Custom domains](/prisma/frontend/websites#custom-domains).

## Packaging

Prisma runs the uploaded artifact without installing dependencies. `@vercel/nft`
traces the installed application's runtime graph. Native addons require a
Linux-compatible build environment; a macOS deployment does not cross-compile them.

## Where next

- [vinext API reference](/providers/prisma/website/vinext).
- [Runnable example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-website-vinext).
- [Websites](/prisma/frontend/websites) and [Compute apps](/prisma/compute/apps).
- [vinext on Cloudflare](/cloudflare/frontend/vinext), [AWS](/aws/frontend/vinext),
  [Fly](/fly/frontend/vinext), [Hetzner](/hetzner/frontend/vinext), and
  [Railway](/railway/frontend/vinext).