# Next.js application
<subtitle>Next.js web app running in a sandbox using Node.js. </subtitle>

Basic Next.js application, including Tailwind and shadcn UI.

> Once the sandbox is in place, the development server will be running on port 3000.

## Template definition

```python
# template.py
from ucloud_sandbox import Template, wait_for_url

template = (
    Template()
    .from_node_image("21-slim")
    .set_workdir("/home/user/nextjs-app")
    .run_cmd(
        'npx create-next-app@14.2.30 . --ts --tailwind --no-eslint --import-alias "@/*" --use-npm --no-app --no-src-dir'
    )
    .run_cmd("npx shadcn@2.1.7 init -d")
    .run_cmd("npx shadcn@2.1.7 add --all")
    .run_cmd("mv /home/user/nextjs-app/* /home/user/ && rm -rf /home/user/nextjs-app")
    .set_workdir("/home/user")
    .set_start_cmd("npx next --turbo", wait_for_url('http://localhost:3000'))
)
```

## Build template

```python
# build.py
from ucloud_sandbox import Template, default_build_logger
from .template import template as nextjsTemplate

Template.build(nextjsTemplate, 'nextjs-app',
    cpu_count=4,
    memory_mb=4096,
    on_build_logs=default_build_logger(),
)
```
