Deploy a Next.js app
Deploy a Next.js app on LILY from a GitHub repository, with the CLI or the console.
This guide deploys a minimal Next.js app with the App Router. LILY detects Next.js by the next dependency in package.json.
Before you start
- A LILY account with GitHub connected, and the
llyCLI installed and signed in. See the Quickstart. - Node.js and npm, to run the app locally.
1. Create the app
Create a directory with these three files:
{
"name": "nextjs-demo",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^16.4.6",
"react": "^19.3.1",
"react-dom": "^19.3.1"
}
}export const metadata = { title: "LILY demo: Next.js" };
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}export default function Home() {
return <main>Hello from Next.js on LILY</main>;
}Install the dependencies and run it locally. Commit the package-lock.json that npm install creates: LILY installs dependencies with npm, pnpm or yarn, depending on the lockfile.
npm install
npm install -D typescript @types/react @types/node
npm run devOpen http://localhost:3000. The page shows "Hello from Next.js on LILY".
2. Push it to GitHub
LILY builds from GitHub, not from your local files.
git init -b main
git add -A && git commit -m "First commit"
gh repo create nextjs-demo --private --source=. --pushAny way of creating the GitHub repository works. LILY needs your GitHub account connected to read a private repository.
3. Deploy
Run this in the project directory:
lly deployNo flags are needed.
lly detects the app, builds it and follows the build until it is live. The output, shortened:
Repository acme/nextjs-demo @ main (origin)
Project nextjs-demo (new)
✓ Source 1 root detected
Detected roots
Root Framework Status Hint
* . nextjs ok package.json contains next
✓ Analyzed
copperfox deployed 3m10s
Apps
App Phase URL Since Note
copperfox deployed https://copperfox.lilylabs.app in 0sStart a new project, pick the repository and follow the steps in Deploy an app. LILY lists the app with the framework nextjs.
What LILY detected
| Setting | Value | From |
|---|---|---|
| Framework | nextjs | next in package.json |
| Port | None listed | Next.js apps are served without a service port |
| Public access | Yes | An app with a detected port is public |
| Environment variables | None | The app reads none |
Check that it worked
Open the address from the summary in a browser, or request it:
curl -s https://copperfox.lilylabs.app | grep -o "Hello from Next.js on LILY"Hello from Next.js on LILYUse the address from the summary in place of copperfox.lilylabs.app.
Known limits
None found with this app, which has one static page. Routes that cannot be compiled are covered under Node fallback.
Use an agent
Deploy this Next.js project to LILY with the lly CLI.
Check that package-lock.json is committed and the branch is pushed to GitHub.
Run `lly deploy -y --json` from the project root. When it is live, request the URL and show me the response.
If it exits with code 7, show me the build log with `lly attach <slug> --build`.