Skip to content

Commit

Permalink
chore: add export ImageResponseOptions (#48418)
Browse files Browse the repository at this point in the history
Exports `ImageResponseOptions` from `next/server`.

## Rationale

Today I do this:

```ts
import { ImageResponseOptions } from "next/dist/compiled/@vercel/og/types";
import { ImageResponse } from "next/server";

export const config = { runtime: "edge" };

export const GET = async (req: Request) => {
  const inter = await getFont({
    family: "Inter",
    weights: [400, 700],
  });

  const options: ImageResponseOptions = {
    width: 1200,
    height: 600,
    fonts: [
      { name: "Inter", data: inter[400], weight: 400 },
      { name: "Inter", data: inter[700], weight: 700 },
    ],
  };

  if (someCond) {
    return new ImageResponse(<>Some JSX</>, options);
  }
  
  // ...

  return new ImageResponse(<>Some other JSX</>, options);
};
```

And I never like importing stuff from an internal path such as
`dist/compiled/...`.
  • Loading branch information
juliusmarminge committed Apr 15, 2023
1 parent 3a78711 commit 97c21f2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/next/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export { userAgentFromString } from 'next/dist/server/web/spec-extension/user-ag
export { userAgent } from 'next/dist/server/web/spec-extension/user-agent'
export { URLPattern } from 'next/dist/compiled/@edge-runtime/primitives/url'
export { ImageResponse } from 'next/dist/server/web/spec-extension/image-response'
export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og/types'

0 comments on commit 97c21f2

Please sign in to comment.