blitz-js / blitz-js/blitz

app router template, `customTemplates` config not work

Open
#4,443 0 comments 0 reactions 0 assignees View on GitHub
kind/bug status/triage
Dominant language
TypeScript
Stars
14.1k
Forks
803
PR merge metrics
No merged PRs in 30d

Description

### What is the problem?

app router template, config not work
```
export const cliConfig: BlitzCliConfig = {
customTemplates: "src/templates",
}
```

### Paste all relevant code snippets here:

```tsx
// src/app/blitz-server.ts
import type { BlitzCliConfig } from "blitz";
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage, simpleRolesIsAuthorized} from "@blitzjs/auth"
import db from "db"
import {BlitzLogger} from "blitz"
import {RpcServerPlugin} from "@blitzjs/rpc"
import {authConfig} from "./blitz-auth-config"

const {api, getBlitzContext, useAuthenticatedBlitzContext, invoke,withBlitzAuth} = setupBlitzServer({
plugins: [
AuthServerPlugin({
...authConfig,
storage: PrismaStorage(db),
isAuthorized: simpleRolesIsAuthorized,
}),
RpcServerPlugin({}),
],
logger: BlitzLogger({}),
})

export {api, getBlitzContext, useAuthenticatedBlitzContext, invoke,withBlitzAuth}

export const cliConfig: BlitzCliConfig = {
customTemplates: "src/templates"
};
```

##### generated file

```tsx
// src/app/notes/new/page.tsx
import { Metadata } from "next";
import { Suspense } from "react";
import { New__ModelName } from "../components/NewNote";

export const metadata: Metadata = {
title: "New Project",
description: "Create a new project",
};

export default function Page() {
return (


Create New Project


Loading...
}>



);
}
```

##### expected use template, but [blitz/packages/generator/templates/route/new/page.tsx at main · blitz-js/blitz · GitHub](https://github.com/blitz-js/blitz/blob/main/packages/generator/templates/route/new/page.tsx)
```tsx
// src/templates/page/new.tsx
import {Routes} from '@blitzjs/next'
if (process.env.parentModel) {
import Link from 'next/link'
import {useParam} from '@blitzjs/next'
import { useRouter } from "next/router"
import {useMutation} from '@blitzjs/rpc'
} else {
import Link from 'next/link'
import { useRouter } from "next/router"
import {useMutation} from '@blitzjs/rpc'
}
import Layout from "src/core/layouts/Layout"
import {Create__ModelName__Schema} from "src/__modelNamesPath__/schemas"
import create__ModelName__ from "src/__modelNamesPath__/mutations/create__ModelName__"
import {__ModelName__Form, FORM_ERROR} from "src/__modelNamesPath__/components/__ModelName__Form"
import { Suspense } from 'react'

const New__ModelName__Page = () => {
const router = useRouter()
if (process.env.parentModel) {
const __parentModelId__ = useParam("__parentModelId__", "number")
}
const [create__ModelName__Mutation] = useMutation(create__ModelName__)

return (

Create New __ModelName__


Loading...}>
<__ModelName__Form
submitText="Create __ModelName__"
schema={Create__ModelName__Schema}
// initialValues={{}}
onSubmit={async (values) => {
try {
const __modelName__ = await create__ModelName__Mutation(
process.env.parentModel
? {...values, __parentModelId__: __parentModelId__!}
: values,
)
await router.push(
process.env.parentModel
? Routes.Show__ModelName__Page({ __parentModelId__: __parentModelId__!, __modelId__: __modelName__.id })
: Routes.Show__ModelName__Page({ __modelId__: __modelName__.id }),
)
} catch (error: any) {
console.error(error)
return {
[FORM_ERROR]: error.toString(),
}
}
}}
/>




__ModelNames__



__ModelNames__





)
}

New__ModelName__Page.authenticate = true

export default New__ModelName__Page

```

### What are detailed steps to reproduce this?

```
-> % blitz new blitz-app-router
Loaded env from /Users/zenochan/Zeno/projects/2509_zeno-station/.env
? Pick your new app template › - Use arrow-keys. Return to submit.
❯ App Router – Full Setup: includes DB and auth (Recommended)

-> % blitz g custom-templates

-> % blitz g pages note title:string
```

### Run `blitz -v` and paste the output here:

```
Blitz version: 3.0.2 (global)
Blitz version: 3.0.2 (local)
macOS Sequoia | darwin-x64 | Node: v20.15.0

Package manager: npm

System:
OS: macOS 15.6.1
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 1.73 GB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
Yarn: 4.9.4 - ~/.nvm/versions/node/v20.15.0/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v20.15.0/bin/npm
npmPackages:
@blitzjs/auth: 3.0.2 => 3.0.2
@blitzjs/next: 3.0.2 => 3.0.2
@blitzjs/rpc: 3.0.2 => 3.0.2
@prisma/client: 5.4.2 => 5.4.2
blitz: 3.0.2 => 3.0.2
next: 15.0.1 => 15.0.1
prisma: 5.4.2 => 5.4.2
react: 19.0.0 => 19.0.0
react-dom: 19.0.0 => 19.0.0
typescript: ^4.8.4 => 4.9.5
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.