Skip to content

Conversation

2chanhaeng
Copy link
Contributor

@2chanhaeng 2chanhaeng commented Aug 6, 2025

Summary

Create @fedify/nextjs to integrate with Next.js and add Next.js option for cli init

Related Issue

Changes

  • Create pacakges/nextjs.
  • Add Next.js option for cli init.
  • Fix typo error in examples/next15-app-router.

Benefits

Now users can conveniently use Next.js and Fedify together more easier.

Checklist

  • Did you add a changelog entry to the CHANGES.md?
  • Did you write some relevant docs about this change (if it's a new feature)?
  • Did you write a regression test to reproduce the bug (if it's a bug fix)? Not a bug fix.
  • Did you write some tests for this change (if it's a new feature)?
    For the test, deployment is required.(I think)
  • Did you run deno task test-all on your machine?

Additional Notes

A subissue needs to fix Next.js example #356

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @2chanhaeng, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've introduced a new @fedify/nextjs package to seamlessly integrate Fedify with Next.js applications. This change also updates the CLI's init command, allowing users to easily scaffold new Fedify projects with Next.js as their chosen web framework, significantly improving the developer experience for building federated applications on Next.js.

Highlights

  • New @fedify/nextjs Package: I've created a dedicated @fedify/nextjs package, providing core utilities like fedifyWith for Next.js middleware and integrateFederation for handling federation requests, enabling Fedify to run within Next.js environments.
  • Enhanced CLI init Command: The fedify cli init command now supports Next.js, allowing users to generate a new project with a pre-configured Next.js setup, including necessary dependencies and a middleware.ts template for Fedify integration.
  • Project Configuration Updates: I've updated the .gitignore to include .pnpm-store/ and adjusted pnpm-lock.yaml and pnpm-workspace.yaml to incorporate the new @fedify/nextjs package and its dependencies, ensuring proper project setup and dependency management.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added component/integration Web framework integration priority/medium Medium priority issues status/in progress In progress type/feature Requests for new features labels Aug 6, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new package, @fedify/nextjs, to integrate Fedify with Next.js. It also adds a Next.js option to the cli init command for easy project scaffolding. The changes look good overall, but I've found a few issues. There's a type issue with a default function parameter in the new Next.js package that could lead to runtime errors. The CLI template for Next.js is missing an important import, which would cause an error for users. I've also pointed out some redundant code in the CLI configuration for consistency. My review includes suggestions to fix these issues.

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

You should mention that the Fedify–Next.js integration requires Next.js 15.5 or higher.

2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 8, 2025
fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)
fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)
fedify-dev#355 (comment)
If you need it, you can use this instead of `fedifyWith`:
```ts
// middleware.ts
import { hasFederationAcceptHeader, integrateFederation } from "@fedify/next";
import { getXForwardedRequest } from "x-forwarded-fetch";

export default function middleware(request: Request) {
  if(hasFederationAcceptHeader(request) {
    integrateFederation(getXForwardedRequest(request))
  }
}
```
Copy link
Contributor Author

@2chanhaeng 2chanhaeng left a comment

Choose a reason for hiding this comment

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

  • 4f17015: Add docs about specified next version.
  • a0ed306: Ignore examples in doc when test doc. Import errors appears because the example code imports assumed module.

Copy link
Contributor

github-actions bot commented Aug 8, 2025

The docs for this pull request have been published:

https://e369a0e6.fedify.pages.dev

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

Looks good in general. Just left few comments, which are all trivial.

Copy link
Contributor Author

@2chanhaeng 2chanhaeng left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

It's really the last one!

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

github-actions bot commented Aug 9, 2025

The latest push to this pull request has been published to JSR and npm as a pre-release:

Package Version JSR npm
@fedify/fedify 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/cli 1.9.0-pr.355.1356+26d28e9a JSR
@fedify/amqp 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/elysia 1.9.0-pr.355.1356+26d28e9a npm
@fedify/express 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/h3 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/nestjs 1.9.0-pr.355.1356+26d28e9a npm
@fedify/postgres 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/redis 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/sqlite 1.9.0-pr.355.1356+26d28e9a JSR npm
@fedify/testing 1.9.0-pr.355.1356+26d28e9a JSR npm

@dahlia dahlia merged commit 538730b into fedify-dev:main Aug 9, 2025
9 of 10 checks passed
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)

Rename `@fedify/nextjs` to `@fedify/next`

fedify-dev#355 (comment)
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
fedify-dev#355 (comment)
If you need it, you can use this instead of `fedifyWith`:
```ts
// middleware.ts
import { hasFederationAcceptHeader, integrateFederation } from "@fedify/next";
import { getXForwardedRequest } from "x-forwarded-fetch";

export default function middleware(request: Request) {
  if(hasFederationAcceptHeader(request) {
    integrateFederation(getXForwardedRequest(request))
  }
}
```
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
2chanhaeng added a commit to 2chanhaeng/fedify that referenced this pull request Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/integration Web framework integration priority/medium Medium priority issues status/in progress In progress type/feature Requests for new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Next.js Integration using Middleware Next.js Integration
2 participants