diff --git a/templates/express/src/entry-server.tsx b/templates/express/src/entry-server.tsx
index fe5e89b6d..f5cf27886 100644
--- a/templates/express/src/entry-server.tsx
+++ b/templates/express/src/entry-server.tsx
@@ -14,38 +14,30 @@ const frames = createFrames({
],
});
-export const handleRequest = frames(async ctx => {
+export const handleRequest = frames(async (ctx) => {
+ if (!ctx.message) {
+ return {
+ image: (
+
+ This is the initial frame which will be shown before the user has
+ interacted with the frame.
+
+ ),
+ buttons: [
- GM, {ctx.message.requesterUserData?.displayName}! Your FID is{" "}
+ image: (
+
+ Hello {ctx.message.requesterUserData?.displayName}! Your FID is{" "}
{ctx.message.requesterFid}
- {", "}
- {ctx.message.requesterFid < 20_000
- ? "you're OG!"
- : "welcome to the Farcaster!"}
-
- ) : (
-
- Say GM
),
- buttons: !ctx.url.searchParams.has("saidGm")
- ? [
-
,
- ]
- : [],
+ buttons: [],
};
});
\ No newline at end of file
diff --git a/templates/hono/src/server.tsx b/templates/hono/src/server.tsx
index 4a4d094b0..52e608bec 100644
--- a/templates/hono/src/server.tsx
+++ b/templates/hono/src/server.tsx
@@ -18,39 +18,31 @@ const frames = createFrames({
],
});
-const handleRequest = frames(async ctx => {
+const handleRequest = frames(async (ctx) => {
+ if (!ctx.message) {
+ return {
+ image: (
+
+ This is the initial frame which will be shown before the user has
+ interacted with the frame.
+
+ ),
+ buttons: [
],
+ };
+ }
+
+ if (!ctx.message.isValid) {
+ throw new Error("Invalid message");
+ }
+
return {
- image: ctx.message ? (
-
- GM, {ctx.message.requesterUserData?.displayName}! Your FID is{" "}
+ image: (
+
+ Hello {ctx.message.requesterUserData?.displayName}! Your FID is{" "}
{ctx.message.requesterFid}
- {", "}
- {ctx.message.requesterFid < 20_000
- ? "you're OG!"
- : "welcome to the Farcaster!"}
-
- ) : (
-
- Say GM
),
- buttons: !ctx.url.searchParams.has("saidGm")
- ? [
-
,
- ]
- : [],
+ buttons: [],
};
});
diff --git a/templates/next/app/frames/frames.ts b/templates/next/app/frames/frames.ts
new file mode 100644
index 000000000..3b6935ad9
--- /dev/null
+++ b/templates/next/app/frames/frames.ts
@@ -0,0 +1,16 @@
+import { farcasterHubContext } from "frames.js/middleware";
+import { createFrames } from "frames.js/next";
+
+export const frames = createFrames({
+ basePath: "/frames",
+ middleware: [
+ farcasterHubContext({
+ // remove if you aren't using @frames.js/debugger or you just don't want to use the debugger hub
+ ...(process.env.NODE_ENV === "production"
+ ? {}
+ : {
+ hubHttpUrl: "http://localhost:3010/hub",
+ }),
+ }),
+ ],
+});
diff --git a/templates/next/app/frames/route.tsx b/templates/next/app/frames/route.tsx
index a4a50ac72..7a754cdcd 100644
--- a/templates/next/app/frames/route.tsx
+++ b/templates/next/app/frames/route.tsx
@@ -1,53 +1,31 @@
-import { farcasterHubContext } from "frames.js/middleware";
-import { createFrames, Button } from "frames.js/next";
-
-const frames = createFrames({
- basePath: '/frames',
- middleware: [
- farcasterHubContext({
- // remove if you aren't using @frames.js/debugger or you just don't want to use the debugger hub
- ...(process.env.NODE_ENV === "production"
- ? {}
- : {
- hubHttpUrl: "http://localhost:3010/hub",
- }),
- }),
- ],
-});
+import { Button } from "frames.js/next";
+import { frames } from "./frames";
const handleRequest = frames(async (ctx) => {
+ if (!ctx.message) {
+ return {
+ image: (
+
+ This is the initial frame which will be shown before the user has
+ interacted with the frame.
+
+ ),
+ buttons: [
],
+ };
+ }
+
+ if (!ctx.message.isValid) {
+ throw new Error("Invalid message");
+ }
+
return {
- image: ctx.message ? (
-
- GM, {ctx.message.requesterUserData?.displayName}! Your FID is{" "}
+ image: (
+
+ Hello {ctx.message.requesterUserData?.displayName}! Your FID is{" "}
{ctx.message.requesterFid}
- {", "}
- {ctx.message.requesterFid < 20_000
- ? "you're OG!"
- : "welcome to the Farcaster!"}
-
- ) : (
-
- Say GM
),
- buttons: !ctx.url.searchParams.has("saidGm")
- ? [
-
,
- ]
- : [],
+ buttons: [],
};
});