Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: @next/next/no-server-import-in-page explanation #36239

Closed
jnleonard3 opened this issue Apr 18, 2022 · 1 comment · Fixed by #38028
Closed

Docs: @next/next/no-server-import-in-page explanation #36239

jnleonard3 opened this issue Apr 18, 2022 · 1 comment · Fixed by #38028
Labels
Documentation Related to Next.js' official documentation. Middleware Related to Next.js Middleware.

Comments

@jnleonard3
Copy link

What is the improvement or update you wish to see?

Can we get some context on why importing from next/server should not be done?

Is there any context that might help us understand?

I am wanting to make some reusable middleware functions that are placed outside of pages, so I need to import NextRequest and NextResponse, and it's unclear to me what I'm at risk of breaking by importing what amounts to type information.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/messages/no-server-import-in-page

@jnleonard3 jnleonard3 added the Documentation Related to Next.js' official documentation. label Apr 18, 2022
@javivelasco javivelasco added Next.js Middleware GA Middleware Related to Next.js Middleware. labels Jun 17, 2022
@kodiakhq kodiakhq bot closed this as completed in #38028 Jun 26, 2022
kodiakhq bot pushed a commit that referenced this issue Jun 26, 2022
This rule was good and kinda made sense when we had nested Middleware.
Now that we have a single Middleware, one might extract logic into different places
and I don't think we should limit importing `NextResponse` or `NextRequest`.

## Related

- Closes #36239
- Closes #37309



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation. Middleware Related to Next.js Middleware.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants