t3-code-android-nightly/.repos/alchemy-effect/examples/neon-website-nextjs/README.md
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

82 lines
4.1 KiB
Markdown

> Runtime acceptance is pending the Neon deployment and browser checks; this example is not yet verified on Neon.
# Neon Website: Next.js
Deploys a real Next.js application with `Neon.Website.Nextjs`.
An App Router page reads `GREETING` on each request. A client component increments a counter and calls `/api/hello` without a database. A server-action form redirects to a result that survives refresh. `/api/stream` emits two SSE messages, `/redirect` returns a temporary redirect, and an unoptimized Next Image renders `/logo.svg`.
The production artifact passes isolated Linux ARM64/glibc Node 24 checks, including Sharp WebP optimization, assets, HEAD, and streaming. Desktop/mobile browser checks against the source-generated artifact pass counters, greeting fetches, server actions, refresh persistence, and the redirect link. Redirects preserve the request protocol, hostname, and port; Next itself normalizes loopback IP hostnames to `localhost`. Fresh Neon deployment reaches the API but fails with `FunctionDeploymentFailed`, so live browser acceptance and updates remain unverified. The full 13-framework live matrix is not green.
## Infrastructure
`alchemy.run.ts` uses `Neon.providers()` and `Alchemy.localState()`.
The helper uses the application root by default. Live deployments without explicit
scope own a Neon Project in Ohio (`aws-us-east-2`), including its normal default
database, and a Node 24 Function. The app does not query that database.
No Docker daemon, container registry, or other cloud provider is used.
Pass an existing `project` or `branch` to reuse it without transferring ownership.
The workspace supplies `alchemy` and `@alchemy.run/frontend-frameworks` through
`workspace:*` dependencies. `@vercel/nft` is installed for Neon artifact tracing.
Install dependencies from the repository root before
running commands in this directory. Authenticate Neon using the Alchemy profile
you intend to deploy with.
## Deploy
```sh
bun run deploy --profile testing
```
The stack returns `url`. Framework configuration, application sources, and public
assets are included in this example; the Website helper owns the deployment adapter.
## Develop
```sh
bun run dev
```
This runs the native framework dev server without creating an implicit Website-owned
Neon backend. Explicit backend resources remain live resources. Apply
`Alchemy.remote()` to the Website Effect to deploy a real Function during dev.
Cloud-only `function` and `domain` outputs are absent locally.
## Verify
```sh
ALCHEMY_PROFILE=testing bun test test/integ.test.ts
```
The integration suite destroys previous stack state, deploys the actual app,
requests its page, dynamic endpoint, verifies the static JSON asset, and destroys the stack.
Set `NO_DESTROY=1` only when intentionally keeping the deployment for inspection.
For browser validation, open the returned URL. Click **count: 0**; it becomes **count: 1**. Click **Load greeting** and check that the greeting appears below the button.
Every app also serves `/example.json` with a framework label and greeting.
## Destroy
```sh
bun run destroy --profile testing
```
## Packaging and security
The Function receives a deterministic ZIP with a root Fetch `index.mjs`; it is not a
listening server or S3 website. Runtime dependencies are traced with `@vercel/nft`.
Only traced pnpm dependency files are materialized, with Node 24 resolution hooks
preserving canonical package identity. Exact-version Sharp Linux ARM64/glibc packages
are fetched with registry integrity checks; incompatible native binaries remain rejected.
Validated ELF addons and shared libraries are accepted. `.env` files, credential files,
and source maps remain excluded.
Framework public environment prefixes are intentionally browser-visible. Keep secrets
out of those variables; `Redacted` protects infrastructure output, not arbitrary
framework build-time substitution. Never put `NEON_API_KEY` in Website `env`.
Optional `domain` registers a custom hostname and returns `domain.cnameTarget`.
Publish a DNS-only CNAME and verify HTTPS independently; registration is not proof
of certificate readiness. Functions have public URLs, so authenticate private
application routes in the handler.