# Next.js Application (Bun)
<subtitle>Next.js web app running in a sandbox using Bun. </subtitle>

A basic Next.js app using Bun, 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_bun_image('1.3')
    .set_workdir('/home/user/nextjs-app')
    .run_cmd('bun create next-app --app --ts --tailwind --turbopack --yes --use-bun .')
    .run_cmd('bunx --bun shadcn@latest init -d')
    .run_cmd('bunx --bun shadcn@latest add --all')
    .run_cmd('mv /home/user/nextjs-app/* /home/user/ && rm -rf /home/user/nextjs-app')
    .set_workdir('/home/user')
    .set_start_cmd('bun --bun run dev --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-bun',
    cpu_count=4,
    memory_mb=4096,
    on_build_logs=default_build_logger(),
)
```
