Next.js

ដេប្លយកម្មវិធី Next.js របស់អ្នក

harvis serves static files, so this works for the part of Next.js that produces static files: static export. Add one line to your config, build, and the CLI takes it from there. Server-rendered routes, API routes, and middleware don't run here — there's no server behind this host.

steps
  1. 01

    Enable static export

    Add "output: 'export'" to next.config.js. Routes using API routes, middleware, or server-side rendering won't build — everything else does.

  2. 02

    Build the app

    Run "npm run build". With static export on, Next.js writes fully rendered HTML, CSS, and JS to an "out" folder instead of starting a server.

  3. 03

    ដេប្លយវា

    ដំណើរការ "npx harvis deploy out" ពី root គម្រោងរបស់អ្នក។ មិនចាំបាច់ config និងមិនចាំបាច់ចូលសម្រាប់ deploy ដំបូងនេះទេ — អ្នកទទួលបាន URL ផ្ទាល់ភ្លាមៗ ព្រមទាំងតំណទាមទារឯកជនមួយ ដើម្បីភ្ជាប់គេហទំព័រទៅគណនីឥតគិតថ្លៃមួយនៅពេលណាដែលអ្នកត្រៀមខ្លួនរួចរាល់។

ដេប្លយ Next.js ដោយពាក្យបញ្ជាតែមួយ

Build គម្រោងរបស់អ្នក រួចប្រគល់ថតលទ្ធផលទៅ harvis។ មិនចាំបាច់មានគណនីសម្រាប់ deploy ដំបូងទេ — អ្នកនឹងទទួលបានតំណភ្ជាប់ផ្ទាល់ និងតំណទាមទារឯកជនមួយ ដើម្បីគ្រប់គ្រងវានៅពេលក្រោយ។

terminal
npm run build
npx harvis deploy out

ចង់អូសឯកសារជំនួសឱ្យប្រើ terminal មែនទេ? Build គម្រោង រួច ទម្លាក់ថតលទ្ធផលនៅទីនេះ ហើយផ្សព្វផ្សាយវាតាមរបៀបដដែល។

git hook

Deploy Next.js on every git push

The command above is one you will run again after every change. A git hook runs it for you: this one already points at out, the folder Next.js builds into.

The folder holding the finished site. "." is the repo root, which is right for hand-written HTML; a static-site generator writes somewhere else.

pre-push fires on every branch and every remote, so a feature branch would publish over your live site. With this on, a push from anywhere else exits early and goes through untouched.

in your repo root
cat > .git/hooks/pre-push <<'EOF'
#!/bin/sh
set -e
npm run build
harvis deploy out
EOF
chmod +x .git/hooks/pre-push

The options, the gotchas and how to share a hook with your team are on the git hook page.

សំណួរអំពីការដេប្លយ Next.js

I use next/image or API routes. Can I still deploy here?

API routes and the default next/image loader need a server, so they don't work under static export. next/image still works if you set images.unoptimized: true (or point loader at an external image service) — everything else in the App or Pages router that doesn't touch the server builds fine.

Do dynamic routes like /blog/[slug] work with static export?

Yes, as long as they implement generateStaticParams (App Router) or getStaticPaths (Pages Router) so Next knows which pages to pre-render at build time. Routes with no way to enumerate their params ahead of time can't be static.

តើការដេប្លយកម្មវិធី Next.js ទៅ harvis ឥតគិតថ្លៃពិតប្រាកដមែនទេ?

បាន មិនចាំបាច់ប្រើកាតទេ។ ដែនកំណត់ឥតគិតថ្លៃគឺឯកសារ ៥០០ និង ៥០ MB ក្នុងមួយគេហទំព័រ ដែលគ្រប់គ្រាន់សម្រាប់ build Next.js static ដោយមានទំហំគ្រប់គ្រាន់។ គេហទំព័រដែលបានផ្សព្វផ្សាយមិនផុតកំណត់ទេ — ពួកវានៅតែដំណើរការរហូតដល់អ្នកលុបពួកវាចេញ។

តើខ្ញុំអាចប្រើ domain ផ្ទាល់ខ្លួនរបស់ខ្ញុំជាមួយគេហទំព័រ Next.js ដែលបានដេប្លយបានទេ?

គេហទំព័រនីមួយៗទទួលបានអាសយដ្ឋាន harvis.page ឥតគិតថ្លៃមួយ ហើយអ្នកអាចជ្រើសរើស subdomain ផ្ទាល់ខ្លួនរបស់អ្នកពី dashboard បន្ទាប់ពីទាមទារវា — ដូចជា my-app.harvis.page ជំនួសឱ្យអាសយដ្ឋានចៃដន្យ។ ការចង្អុល domain ដែលអ្នកមានស្រាប់ (ដូចជា mystore.com) ទៅកាន់គេហទំព័រនេះមិនទាន់អាចធ្វើបានទេនៅឡើយ។

តើវាខុសពីការដេប្លយ Next.js ទៅ Vercel ឬ Netlify យ៉ាងដូចម្តេច?

Vercel និង Netlify ត្រូវបានបង្កើតឡើងជុំវិញការភ្ជាប់ Git repo និងដំណើរការ build របស់អ្នកនៅលើ server របស់ពួកគេ ជាមួយ dashboard មួយសម្រាប់កំណត់រចនាសម្ព័ន្ធ។ harvis រំលងអ្វីៗទាំងនោះទាំងអស់៖ អ្នក build នៅមូលដ្ឋាន (ឬនៅក្នុង CI ផ្ទាល់ខ្លួនរបស់អ្នក) ដំណើរការពាក្យបញ្ជា CLI តែមួយប្រឆាំងនឹងថតលទ្ធផល រួចទទួលបានតំណភ្ជាប់មួយ — មិនចាំបាច់រៀបចំគម្រោង និងមិនចាំបាច់មានគណនីទេ រហូតដល់អ្នកចង់រក្សាគេហទំព័រនោះ។

other frameworks

កំពុងដេប្លយអ្វីផ្សេងទៀតមែនទេ?

រូបមន្តដូចគ្នាគ្រប់ទីកន្លែង — build វា រួច npx harvis deploy លទ្ធផល។