|
| 1 | +# Troubleshooting |
| 2 | + |
| 3 | +## Image not rendering |
| 4 | + |
| 5 | +### Image too large |
| 6 | + |
| 7 | +If the image is not rendering, it may be too large. |
| 8 | + |
| 9 | +- If you are including a full size external `<img>` element, consider passing the external image as a string instead: |
| 10 | + |
| 11 | +```tsx |
| 12 | +return { |
| 13 | + image: "https://example.com/image.jpg", |
| 14 | +}; |
| 15 | +``` |
| 16 | + |
| 17 | +- Try resizing it to a smaller size via the `imageOptions` of the returned `FrameDefinition`. |
| 18 | + |
| 19 | +```tsx |
| 20 | +return { |
| 21 | + image: <div>...</div>, |
| 22 | + imageOptions: { |
| 23 | + width: 100, |
| 24 | + height: 100, |
| 25 | + }, |
| 26 | +}; |
| 27 | +``` |
| 28 | + |
| 29 | +### Image wrong format |
| 30 | + |
| 31 | +If the image is not rendering, it may be in the wrong format. SVG images are typically not supported on mobile. |
| 32 | + |
| 33 | +## Initial frame not loading |
| 34 | + |
| 35 | +Ensure that the `fetchMetadata` URL is correct and that it is inside the `other` folder for Next.js. |
| 36 | + |
| 37 | +### `VERCEL_URL` environment variable |
| 38 | + |
| 39 | +If you are using Vercel, the `VERCEL_URL` environment variable is not a fully qualified URL and may cause issues with `fetchMetadata`. You will have to prepend the protocol `VERCEL_URL`. |
| 40 | + |
| 41 | +```tsx |
| 42 | +export async function generateMetadata() { |
| 43 | + const frameMetadata = await fetchMetadata( |
| 44 | + new URL( |
| 45 | + "/frames", |
| 46 | + process.env.VERCEL_URL |
| 47 | + ? `https://${process.env.VERCEL_URL}` |
| 48 | + : "http://localhost:3000" |
| 49 | + ) |
| 50 | + ); |
| 51 | + |
| 52 | + return { |
| 53 | + title: "My page", |
| 54 | + other: { |
| 55 | + ...frameMetadata, |
| 56 | + }, |
| 57 | + }; |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +### Vercel authentication |
| 62 | + |
| 63 | +When deploying to Vercel, your site will not automatically be accessible to the public. You will need to disable Vercel Authentication under `Settings > Deployment Protection > Vercel Authentication` |
| 64 | + |
| 65 | +## Import type errors |
| 66 | + |
| 67 | +If you are getting type errors when importing `frames.js`, you may need to change the `moduleResolution` in your `tsconfig.json` from `node` to `nodenext`. |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "compilerOptions": { |
| 72 | + "moduleResolution": "nodenext" |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +## Unable to access frame message on initial frame |
| 78 | + |
| 79 | +The initial frame is accessed via a GET request and does not have access to frame message and hence user data. |
| 80 | + |
| 81 | +## Type error: Route ... does not match the required types of a Next.js Route |
| 82 | + |
| 83 | +If you are getting this error you are exporting something other than a Next.js route from a `route.tsx` or `page.tsx` file. |
| 84 | + |
| 85 | +We recommend creating a new file for your `frames` app and importing it in the routes that use it. |
| 86 | + |
| 87 | +### Example |
| 88 | + |
| 89 | +Frames app file |
| 90 | + |
| 91 | +```tsx [frames.ts] |
| 92 | +import { createFrames } from "frames.js/next"; |
| 93 | + |
| 94 | +export const frames = createFrames({ |
| 95 | + basePath: "/frames", |
| 96 | +}); |
| 97 | +``` |
| 98 | + |
| 99 | +Initial page route |
| 100 | + |
| 101 | +```tsx [route.tsx] |
| 102 | +import { frames } from "./frames"; |
| 103 | + |
| 104 | +export const GET = frames(async (ctx) => { |
| 105 | + // ctx.message is not available in the initial frame |
| 106 | + return { |
| 107 | + image: <div>...</div>, |
| 108 | + buttons: [ |
| 109 | + <Button action="post" target="/my-route"> |
| 110 | + Next |
| 111 | + </Button>, |
| 112 | + ], |
| 113 | + }; |
| 114 | +}); |
| 115 | +``` |
| 116 | + |
| 117 | +Frame action handler route |
| 118 | + |
| 119 | +```tsx [my-route/route.tsx] |
| 120 | +import { frames } from "../frames"; |
| 121 | + |
| 122 | +export const POST = frames(async (ctx) => { |
| 123 | + // Do something with ctx.message |
| 124 | + // ... |
| 125 | + |
| 126 | + return { |
| 127 | + image: <div>...</div>, |
| 128 | + buttons: [ |
| 129 | + // ... |
| 130 | + ], |
| 131 | + }; |
| 132 | +}); |
| 133 | +``` |
| 134 | + |
| 135 | +## Combining old and new SDKs |
| 136 | + |
| 137 | +You cannot use the `<FrameComponent>`, `<FrameButton>` and `<FrameImage>` components from the old SDK (`frames.js/next/server`) with the new SDK (`frames.js/next`). |
| 138 | + |
| 139 | +The new SDK uses a [`FrameDefinition`](/reference/core/createFrames#framedefinition) object to define a frame. |
0 commit comments