diff --git a/create-app.ts b/create-app.ts
index 70d7b40dc437cae91c7ee152719abd6e0075cae4..25c47dbd0bcd72a01625c2fadd0b04fda7da22be 100644
--- a/create-app.ts
+++ b/create-app.ts
@@ -88,7 +88,7 @@ export async function createApp({
       path.join(root, "README.md"),
     );
   } else {
-    await installTemplate({ ...args, backend: true });
+    await installTemplate({ ...args, backend: true, forBackend: framework });
   }
 
   process.chdir(root);
diff --git a/templates/index.ts b/templates/index.ts
index d6e5cd61fd75351abde00cebb7d07d0c7a6acb1f..a9f0998eb2315ee1e2166904e548d14db7fb5b00 100644
--- a/templates/index.ts
+++ b/templates/index.ts
@@ -103,6 +103,7 @@ const installTSTemplate = async ({
   ui,
   eslint,
   customApiPath,
+  forBackend,
 }: InstallTemplateArgs) => {
   console.log(bold(`Using ${packageManager}.`));
 
@@ -120,6 +121,26 @@ const installTSTemplate = async ({
     rename,
   });
 
+  /**
+   * If the backend is next.js, rename next.config.app.js to next.config.js
+   * If not, rename next.config.static.js to next.config.js
+   */
+  if (framework == "nextjs" && forBackend === "nextjs") {
+    const nextConfigAppPath = path.join(root, "next.config.app.js");
+    const nextConfigPath = path.join(root, "next.config.js");
+    await fs.rename(nextConfigAppPath, nextConfigPath);
+    // delete next.config.static.js
+    const nextConfigStaticPath = path.join(root, "next.config.static.js");
+    await fs.rm(nextConfigStaticPath);
+  } else if (framework == "nextjs" && typeof forBackend === "undefined") {
+    const nextConfigStaticPath = path.join(root, "next.config.static.js");
+    const nextConfigPath = path.join(root, "next.config.js");
+    await fs.rename(nextConfigStaticPath, nextConfigPath);
+    // delete next.config.app.js
+    const nextConfigAppPath = path.join(root, "next.config.app.js");
+    await fs.rm(nextConfigAppPath);
+  }
+
   /**
    * Copy the selected chat engine files to the target directory and reference it.
    */
diff --git a/templates/types.ts b/templates/types.ts
index 4bcaf5c7bb8464641e964e4fff74c36393f47fdb..926dddd5d97899e0886f6c2fc788906d168363e4 100644
--- a/templates/types.ts
+++ b/templates/types.ts
@@ -17,4 +17,5 @@ export interface InstallTemplateArgs {
   eslint: boolean;
   customApiPath?: string;
   openAIKey?: string;
+  forBackend?: string;
 }
diff --git a/templates/types/simple/nextjs/next.config.js b/templates/types/simple/nextjs/next.config.app.js
similarity index 100%
rename from templates/types/simple/nextjs/next.config.js
rename to templates/types/simple/nextjs/next.config.app.js
diff --git a/templates/types/simple/nextjs/next.config.static.js b/templates/types/simple/nextjs/next.config.static.js
new file mode 100644
index 0000000000000000000000000000000000000000..166b3e67d75ddc6d594b1c3d0960cc51f54b13b9
--- /dev/null
+++ b/templates/types/simple/nextjs/next.config.static.js
@@ -0,0 +1,13 @@
+/** @type {import('next').NextConfig} */
+const nextConfig = {
+  output: "export",
+  images: { unoptimized: true },
+  experimental: {
+    serverComponentsExternalPackages: ["llamaindex"],
+    outputFileTracingIncludes: {
+      "/*": ["./cache/**/*"],
+    },
+  },
+};
+
+module.exports = nextConfig;
diff --git a/templates/types/streaming/nextjs/next.config.js b/templates/types/streaming/nextjs/next.config.app.js
similarity index 100%
rename from templates/types/streaming/nextjs/next.config.js
rename to templates/types/streaming/nextjs/next.config.app.js
diff --git a/templates/types/streaming/nextjs/next.config.static.js b/templates/types/streaming/nextjs/next.config.static.js
new file mode 100644
index 0000000000000000000000000000000000000000..166b3e67d75ddc6d594b1c3d0960cc51f54b13b9
--- /dev/null
+++ b/templates/types/streaming/nextjs/next.config.static.js
@@ -0,0 +1,13 @@
+/** @type {import('next').NextConfig} */
+const nextConfig = {
+  output: "export",
+  images: { unoptimized: true },
+  experimental: {
+    serverComponentsExternalPackages: ["llamaindex"],
+    outputFileTracingIncludes: {
+      "/*": ["./cache/**/*"],
+    },
+  },
+};
+
+module.exports = nextConfig;