| 1 | import * as Namespace from "../../Namespace.ts"; |
| 2 | import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts"; |
| 3 | |
| 4 | /** Configuration for a Neon Nextjs website. */ |
| 5 | export type NextjsProps = FrameworkSiteProps; |
| 6 | |
| 7 | /** |
| 8 | * Next.js on Neon Functions using next build and the existing Node custom-server target, not OpenNext. The artifact contains .next, public, configuration, and traced runtime dependencies, preserving installed package versions. |
| 9 | * |
| 10 | * Native framework development and HMR run without Neon cloud resources. |
| 11 | * Apply `Alchemy.remote()` to use the live Function deployment during dev. |
| 12 | * Packaging requires the optional `@vercel/nft` peer dependency. |
| 13 | * Exact-version Sharp Linux ARM64/glibc packages are integrity-checked and staged. |
| 14 | * The example artifact passes isolated Node 24 image optimization and desktop/mobile |
| 15 | * counter, server-action, and redirect navigation checks. The Fetch bridge preserves |
| 16 | * request-origin metadata without rewriting redirect responses. Initial live deployment |
| 17 | * and desktop/mobile interactions are verified. Updates may still serve the previous |
| 18 | * artifact after Neon accepts a new deployment; full lifecycle acceptance remains incomplete. |
| 19 | * |
| 20 | * ### Creating a Website |
| 21 | * **Example:** Nextjs application |
| 22 | * ```typescript |
| 23 | * const site = yield* Neon.Website.Nextjs("Web", { |
| 24 | * rootDir: "./app", |
| 25 | * }); |
| 26 | * ``` |
| 27 | * |
| 28 | * ### Deployment Configuration |
| 29 | * **Example:** Existing project and custom hostname |
| 30 | * ```typescript |
| 31 | * const site = yield* Neon.Website.Nextjs("Web", { |
| 32 | * project, |
| 33 | * domain: "www.example.com", |
| 34 | * env: { API_BASE: "https://api.example.com" }, |
| 35 | * function: { name: "Website" }, |
| 36 | * }); |
| 37 | * ``` |
| 38 | * |
| 39 | * @resource |
| 40 | * @product Website |
| 41 | */ |
| 42 | export const Nextjs = (id: string, props: NextjsProps = {}) => |
| 43 | makeFrameworkSite(id, props, { |
| 44 | framework: "@alchemy.run/frontend-frameworks/nextjs/neon", |
| 45 | target: "@alchemy.run/frontend-frameworks/nextjs/neon", |
| 46 | layout: "next", |
| 47 | }).pipe(Namespace.push(id)); |