Skip to content

Add Next.js feature option and update documentation#439

Open
DiyRex wants to merge 4 commits into
Melkeydev:mainfrom
DiyRex:feat/nextjs-feature-flag
Open

Add Next.js feature option and update documentation#439
DiyRex wants to merge 4 commits into
Melkeydev:mainfrom
DiyRex:feat/nextjs-feature-flag

Conversation

@DiyRex

@DiyRex DiyRex commented Apr 23, 2026

Copy link
Copy Markdown

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

Add Next.js as a first-class frontend option in the advanced-features set, alongside the existing React (Vite) and HTMX/Templ choices. Users who want a modern full-stack setup with App Router, TypeScript, Tailwind, and shadcn/ui can now scaffold everything with a single flag, wired up to the Go backend out of the box.

Description of Changes

  • New --feature nextjs flag — added Nextjs constant in cmd/flags/advancedFeatures.go and appended it to AllowedAdvancedFeatures. Shows up automatically in go-blueprint create --help.
  • TUI checkbox — new "Next.js" item in the advanced-features multi-select (cmd/steps/steps.go).
  • Mutual exclusion — Next.js ⟂ React ⟂ HTMX. Selecting Next.js clears React/HTMX/Tailwind flags in both cmd/create.go and cmd/program/program.go.
  • CreateNextJSProject() in cmd/program/program.go that:
    • Runs npx create-next-app@latest frontend --ts --app --eslint --src-dir --tailwind --use-npm --import-alias "@/*" --no-turbopack
    • Initializes shadcn/ui non-interactively (npx shadcn@latest init -d) and adds button + card as baseline components
    • Writes frontend/.env.local with NEXT_PUBLIC_API_URL=http://localhost:<PORT> (read from the project's root .env, same pattern used for React's VITE_PORT)
    • Writes frontend/next.config.mjs with output: "standalone" and an /api/* → Go backend rewrites() rule so server-side fetches work without CORS
    • Overwrites src/app/page.tsx with a demo page using shadcn <Button> + <Card> that fetches from the Go backend
  • Embedded templates — new files under cmd/template/advanced/files/nextjs/ (page.tsx.tmpl, next.config.mjs.tmpl) and matching //go:embed + accessors in cmd/template/advanced/routes.go.
  • Docker integration — added {{ if .AdvancedOptions.nextjs }} blocks in Dockerfile.tmpl (multi-stage build using Next's standalone output, runs on :3000) and docker_compose.yml.tmpl (frontend service with NEXT_PUBLIC_API_URL pointing at the app service).
  • Makefile — extended run target's conditional so make run boots both the Go server and the Next.js dev server. Templ/Tailwind build steps are correctly skipped when nextjs is selected.
  • Docs — new docs/docs/advanced-flag/nextjs.md and nav entry in docs/mkdocs.yml. README's Advanced Features list and usage examples updated (satisfies issue 📋Update documentation if the PR introduces a new feature!📋 #218).

CLI example

go-blueprint create \
  --name myapp \
  --framework chi \
  --driver postgres \
  --advanced \
  --feature nextjs \
  --feature docker \
  --git commit

Local verification

  • go build ./... and go vet ./... pass.
  • Non-interactive scaffold verified: frontend/ contains Next.js 15 App Router layout with src/, components/ui/button.tsx, components/ui/card.tsx, .env.local, next.config.mjs.
  • make run starts Go (:8080) and Next.js (:3000) together; demo page's "Fetch from Go server" button round-trips successfully.
  • make docker-run with --feature nextjs --feature docker boots both services.
  • Mutual exclusion: --feature nextjs --feature react → only Next.js takes effect; no .templ artifacts when --feature nextjs --feature htmx combined.

Note on CI status

All failing checks on this PR are pre-existing upstream CI issues unrelated to this change. Last successful merge on main was in July 2025, and every PR opened against the repo since Q4 2025 hits the same failures because the Go ecosystem has moved past the pins in .github/workflows/:

  • Linting Generated Blueprints Core / Advanced — runner pins Go 1.23 (.github/workflows/generate-linter-*.yml), but transitive deps of the supported database drivers now require newer Go:

    • filippo.io/edwards25519 v1.2.0 (pulled via go-sql-driver/mysql) requires Go ≥ 1.24
    • golang.org/x/sys v0.43.0 (pulled via several framework deps) requires Go ≥ 1.25

    Result: go get inside the generated project fails → no .go files get written → golangci-lint reports context loading failed: no go files to analyze (exit 5). This is a deadlock: bumping the generated project's go directive unblocks go get but then trips golangci-lint v1.63.4 (built with Go 1.23), which refuses projects whose go directive exceeds its own build version (the Go language version (go1.23) used to build golangci-lint is lower than the targeted Go version).

    Fix requires bumping the workflow pinsgo-version: '1.23.x''1.24.x' (or 'stable') and golangci-lint@v1.63.4v1.64+. I intentionally left the workflow files untouched in this PR but am happy to add that bump if maintainers prefer.

  • Integrations Test — scylla cellinternal/database/database_test.go:38:26: cannot use port (constant "19042/tcp" of string type nat.Port) as string value in argument to wait.ForListeningPort. testcontainers-go changed nat.Port type; the scylla template needs a string(port) cast. Unrelated to Next.js; fix is a one-line change to the scylla database test template.

Locally, with Go 1.24+ and a recent golangci-lint, the full 147-job matrix passes on my feature branch (I reproduced the CI steps 1-for-1 — script -q /dev/null -c "go run main.go create -n <fw> -f <fw> -d <db> -g <git>" then golangci-lint run). I can provide logs or a screencast if that helps review.

Checklist

DiyRex added 4 commits April 22, 2026 21:13
… alongside the existing React/HTMX options.\nScaffolds a Next.js 15 app via create-next-app (App Router, TS,\nTailwind, ESLint, src/, @/* alias) and initializes shadcn/ui with\nbutton + card components. Writes frontend/.env.local with\nNEXT_PUBLIC_API_URL pointing at the Go backend and a next.config.mjs\nwith standalone output and an /api/* proxy rewrite.\n\nMutually exclusive with React and HTMX. Integrates with the docker\nand makefile templates (frontend service on :3000, make run starts\nboth Go + Next dev servers). Docs page added under advanced-flag/.
…s required by generator (filippo.io/edwards25519 v1.2.0\nneeds Go >= 1.24; golang.org/x/sys v0.43.0 needs Go >= 1.25) made\n'go get' fail inside freshly-generated projects on CI runners pinned\nto Go 1.23. With GOTOOLCHAIN=auto (default on Go 1.21+), bumping the\ngenerated go.mod's go directive to 1.25.0 lets the toolchain\ntransparently fetch a compatible Go version at install time.\n\nAlso bumps the go-blueprint repo's own go directive to 1.24.0 so\nbuilding the generator itself doesn't trip the same limit.
…tive deps required by generator (filippo.io/edwards25519 v1.2.0\nneeds Go >= 1.24; golang.org/x/sys v0.43.0 needs Go >= 1.25) made\n'go get' fail inside freshly-generated projects on CI runners pinned\nto Go 1.23. With GOTOOLCHAIN=auto (default on Go 1.21+), bumping the\ngenerated go.mod's go directive to 1.25.0 lets the toolchain\ntransparently fetch a compatible Go version at install time.\n\nAlso bumps the go-blueprint repo's own go directive to 1.24.0 so\nbuilding the generator itself doesn't trip the same limit."

This reverts commit d308ab7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant