Skip to content

IK-2197 Astro Integration for Imagekit#1

Closed
SwarnimDoegar wants to merge 31 commits intomainfrom
IK-2197
Closed

IK-2197 Astro Integration for Imagekit#1
SwarnimDoegar wants to merge 31 commits intomainfrom
IK-2197

Conversation

@SwarnimDoegar
Copy link
Copy Markdown
Collaborator

No description provided.

@SwarnimDoegar SwarnimDoegar marked this pull request as draft April 9, 2026 10:51
@SwarnimDoegar SwarnimDoegar marked this pull request as draft April 9, 2026 10:51
@SwarnimDoegar SwarnimDoegar requested a review from Copilot April 9, 2026 10:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Astro-based monorepo setup for @imagekit/astro, including core components/helpers and a Playwright-driven test app to validate generated ImageKit URLs and rendered markup.

Changes:

  • Introduces @imagekit/astro package with IKImage, IKVideo, IKAstroImage, IKOgImage, shared config resolution, and a getImagekitUrl helper.
  • Adds a test-app Astro project with component demo pages and Playwright E2E tests + snapshots.
  • Adds CI workflows for building, packing, running E2E tests, and publishing on release.

Reviewed changes

Copilot reviewed 38 out of 43 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Defines monorepo packages (imagekit-astro, test-app).
package.json Adds monorepo scripts for build and E2E.
.npmrc pnpm hoisting configuration.
.gitignore Ignores build/test/env artifacts at repo root.
.github/workflows/nodejs.yml CI build + pack + E2E execution.
.github/workflows/npmpublish.yml Release publish workflow with pack + E2E gate.
README.md New top-level SDK documentation and usage examples.
LICENSE Adds MIT license.
imagekit-astro/package.json Defines package exports/scripts/deps for @imagekit/astro.
imagekit-astro/index.ts Public package entrypoint exporting components, helper re-exports, and types.
imagekit-astro/tsup.config.ts tsup build config (helpers bundle + dts).
imagekit-astro/tsconfig.json TS config for package typing/emit settings.
imagekit-astro/src/env.d.ts Astro client type references.
imagekit-astro/src/lib/imagekit.ts Env/prop-based config resolution.
imagekit-astro/src/helpers/getImagekitUrl.ts Programmatic ImageKit URL builder helper.
imagekit-astro/src/helpers/index.ts Helper barrel export.
imagekit-astro/src/types/index.ts Component prop types.
imagekit-astro/src/constants/sizes.ts OG image default dimensions.
imagekit-astro/src/components/IKImage.astro Responsive/non-responsive <img> wrapper around ImageKit URL generation.
imagekit-astro/src/components/IKVideo.astro <video> wrapper around ImageKit URL generation.
imagekit-astro/src/components/IKAstroImage.astro Uses astro:assets <Image> with ImageKit URL/transformation integration.
imagekit-astro/src/components/IKOgImage.astro Generates OG/Twitter meta tags with ImageKit URLs.
imagekit-astro/helpers/package.json Helpers subpath package metadata.
imagekit-astro/imagekit-astro-1.0.0.tgz Packed artifact added to repo.
test-app/package.json Test app scripts/deps for Astro + Playwright.
test-app/tsconfig.json Astro strict TS config for test app.
test-app/src/env.d.ts Astro client type references for test app.
test-app/astro.config.mjs Astro config (remote image domains).
test-app/src/pages/index.astro Test app landing page navigation.
test-app/src/pages/images.astro IKImage demo/test cases.
test-app/src/pages/videos.astro IKVideo demo/test cases.
test-app/src/pages/astro-images.astro IKAstroImage demo/test cases.
test-app/playwright.config.ts Playwright config with web server + snapshot template.
test-app/e2e/images.spec.ts E2E snapshot test for /images.
test-app/e2e/videos.spec.ts E2E snapshot test for /videos.
test-app/e2e/astro-images.spec.ts E2E assertions for /astro-images (attributes + URL behavior).
test-app/e2e/snapshot/* Stored Playwright snapshots for the E2E tests.
test-app/README.md Test app usage + covered test cases.
test-app/.gitignore Ignores test-app build/test artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread imagekit-astro/src/components/IKAstroImage.astro Outdated
Comment thread imagekit-astro/src/components/IKOgImage.astro Outdated
Comment thread imagekit-astro/package.json Outdated
Comment thread test-app/src/pages/index.astro
Comment thread test-app/e2e/images.spec.ts
Comment thread test-app/e2e/videos.spec.ts
@SwarnimDoegar SwarnimDoegar marked this pull request as ready for review April 22, 2026 21:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 54 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • imagekit-astro/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread imagekit-astro/src/services/imagekit-service.ts Outdated
Comment thread test-app/README.md
Comment thread imagekit-astro/src/server/uploadAuth.ts Outdated
Comment thread test-app/src/pages/upload.astro
Comment thread test-app/astro.config.mjs
Comment thread imagekit-astro/package.json
SwarnimDoegar and others added 3 commits April 23, 2026 14:48
Comment thread imagekit-astro/src/types/index.ts Outdated
height?: number;

/** Image format override */
format?: 'auto' | 'webp' | 'jpg' | 'jpeg' | 'png' | 'gif' | 'svg' | 'mp4' | 'webm' | 'avif' | 'orig';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either Transformation['format'] (consistency) or a narrower OG-image-only union (correctness for use case not video formats), what do you think?

Comment on lines +6 to +11
type Props = RemoteImageProps & ImageProps;

const {
class: className,
...props
} = Astro.props;
Copy link
Copy Markdown

@aman-imagekit aman-imagekit Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] type Props defined above is not used while destructuring.

Copy link
Copy Markdown
Collaborator Author

@SwarnimDoegar SwarnimDoegar Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the structure that needs to be followed in .astro files. Astro automatically applies the Props type to Astro.props. Even I felt that it is weird 😅, but that's the standard.

width: Math.round(width * scaleFactor),
height: Math.round(height * scaleFactor),
};
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding a 25MP clamp in the SDK feels too opinionated, since ImageKit supports >25MP depending on plan.
Can we remove this cap (or make it configurable) if Astro functionality remains unaffected?

SwarnimDoegar and others added 3 commits April 29, 2026 14:28
@imagekitio
Copy link
Copy Markdown
Contributor

Few doubts:

  1. Astro.CustomImageProps type declarations missing for transformations (or other Imagekit specific prop)
  2. Why did we implement our responsive strategy given Astro has its own? We can map position, fit, quality to our transformations when generating url. We can ignore format and background. We just have to implement getURL and Astro will call it per width in widths/densities.
  3. Why do we need IKImage, when our service already modifies Astro’s Image component?
  4. In our docs of video player we have integration with React, Vue and that will need Astro too.

* Dynamically imports `inferRemoteSize` from `astro:assets`.
* Available since Astro 4.12. Returns `undefined` on older versions.
*/
async function tryInferRemoteSize(url: string): Promise<{ width: number; height: number } | undefined> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be called at build time if width is not passed. Correct?

Wouldn't it be better to make width and height mandatory like Astro and ignore inferSize property?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is called at build time.
I kept it to keep the interface as close to the astro Image component as possible, to make it more seamless to use as a drop-in replacement for the astro image component.

@imagekitio imagekitio closed this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants