1---
2title: Vinext
3description: Deploy vinext to AWS with the shared Website API, native local development, and a platform-specific data cache.
4sidebar:
5 order: 9.6
6---
7
8import { Code, Tabs, TabItem } from "@astrojs/starlight/components";
9
10export const devDeps = "@alchemy.run/frontend-frameworks";
11
12`AWS.Website.Vinext` builds with the Vinext Vite API for production and runs native
13`vinext dev` locally. The React Server Components handler runs on a streaming Lambda Function URL.
14S3 stores assets and CloudFront routes asset requests to S3 and other requests
15to Lambda. This uses vinext, not OpenNext.
16
17The Lambda target supports **App Router** applications. Use a Node deployment
18target such as [Prisma](/prisma/frontend/vinext) or [Fly](/fly/frontend/vinext)
19for Pages Router applications.
20
21## Install
22
23Keep `vinext`, `react`, `react-dom`, and `react-server-dom-webpack` in your
24application dependencies, with `vite` and `@vitejs/plugin-rsc` for building.
25Use vinext **1.0.0-beta.10 or newer**. Alchemy uses its standalone packaging
26to include external runtime dependencies in the Lambda archive. Add the Alchemy integration:
27
28<Tabs syncKey="pkgManager">
29 <TabItem label="bun" icon="bun"><Code code={`bun add -d ${devDeps}`} lang="sh" /></TabItem>
30 <TabItem label="npm" icon="npm"><Code code={`npm install -D ${devDeps}`} lang="sh" /></TabItem>
31 <TabItem label="pnpm" icon="pnpm"><Code code={`pnpm add -D ${devDeps}`} lang="sh" /></TabItem>
32 <TabItem label="yarn" icon="seti:yarn"><Code code={`yarn add -D ${devDeps}`} lang="sh" /></TabItem>
33</Tabs>
34
35## Configure vinext
36
37```typescript
38// vite.config.ts
39import { defineConfig } from "vite";
40import vinext from "vinext";
41
42export default defineConfig({
43 plugins: [vinext({ prerender: true })],
44});
45```
46
47Alchemy injects the target-specific data-cache adapter during deployment.
48No Alchemy plugin is required in `vite.config.ts`; deployment settings belong on
49`Website.Vinext`. Leave Cloudflare plugins and Worker entrypoints out of this application.
50
51## Declare the Website
52
53```typescript
54// alchemy.run.ts
55import * as AWS from "alchemy/AWS";
56
57export const Website = AWS.Website.Vinext("Website", {
58 rootDir: ".",
59});
60```
61
62`rootDir`, `env`, `memo`, `assets`, `dev`, and `domain` use the same vocabulary
63as the other Website constructors. Framework configuration stays in
64`vite.config.ts` rather than a nested server configuration object.
65
66## Add it to the Stack
67
68```typescript
69import * as Alchemy from "alchemy";
70import * as Effect from "effect/Effect";
71
72export default Alchemy.Stack(
73 "MyVinextSite",
74 { providers: AWS.providers(), state: Alchemy.localState() },
75 Effect.gen(function* () {
76 const site = yield* Website;
77 return { url: site.url };
78 }),
79);
80```
81
82Keep the local state available for subsequent deploys and teardown.
83
84## Add environment variables
85
86```typescript
87export const Website = AWS.Website.Vinext("Website", {
88 env: { GREETING: "Hello from vinext on AWS!" },
89});
90```
91
92`env` is available during build, development, and production. Server code reads
93`process.env`; public framework variables may be compiled into browser assets.
94Keep secrets out of public keys and wrap credentials in `Redacted`.
95
96## Read the runtime environment
97
98```typescript
99// app/api/hello/route.ts
100export function GET(request: Request) {
101 const name = new URL(request.url).searchParams.get("name") ?? "world";
102 return Response.json({ name, greeting: process.env.GREETING ?? "hello" });
103}
104```
105
106Request-dependent route handlers read the production environment. A prerendered
107page reflects its build-time inputs instead.
108
109## Configure the data cache
110
111The Website provisions an S3 bucket for ISR and `"use cache"`, sets
112`CACHE_BUCKET_NAME`, and grants the Lambda access. The build selects the S3
113adapter. Local development uses memory and creates no bucket.
114
115## Local development
116
117```sh
118bun alchemy dev
119```
120
121The Website runs `vinext dev` with native HMR and creates no cloud resources.
122Other resources declared in the Stack retain their own provider behavior.
123Apply `.pipe(Alchemy.remote())` to the Website for a live deployment during dev.
124
125## Custom domains
126
127```typescript
128const site = yield* AWS.Website.Vinext("Web", {
129 domain: "app.example.com",
130});
131```
132
133See [Website domains](/aws/frontend/websites) for platform-specific DNS and
134certificate configuration.
135
136## Where next
137
138- [vinext API reference](/providers/aws/website/vinext).
139- [Runnable example](https://github.com/alchemy-run/alchemy/tree/main/examples/aws-website-vinext).
140- [Website overview](/aws/frontend/websites).
141- [vinext on Cloudflare](/cloudflare/frontend/vinext) and [Prisma](/prisma/frontend/vinext).