Skip to content

rust api in nextjs app? #69

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

Closed
YuriGor opened this issue Jul 24, 2022 · 3 comments
Closed

rust api in nextjs app? #69

YuriGor opened this issue Jul 24, 2022 · 3 comments

Comments

@YuriGor
Copy link

YuriGor commented Jul 24, 2022

Hi all, is there any normal way to have rust api within nextjs app?
In nextjs all the APIs are supposed to be in /pages/api/

If I try to add /api alongside with /pages/api
/api - works, but /pages/api doesn't

If I try to place rust code in /pages/api and in vercel.json set:

{
  "functions": {
    "pages/api/**/*.rs": {
      "runtime": "[email protected]"
    }
}

it doesn't work, rs file is not compiling.

If I try to move everything under /api from /pages/api - multiple issues with webpack/fetch/next-XXX plugins appear.

Maybe there is some more vercel or nextjs configs I can use?

Or wasm is only option in my case? (except creating separate API project only for Rust)

@abcd-ca
Copy link
Contributor

abcd-ca commented Feb 4, 2023

I also encountered this issue. I tested a non-nextjs app and ran it with vercel dev and it worked. I could not get a rust api to work in nextjs at all even when trying to relocate the /api dir.

@ecklf
Copy link
Collaborator

ecklf commented Mar 13, 2023

Hey we released a new runtime in #80 which now also provides examples to integrate with Next.js. Happy about every feedback.

@ecklf ecklf closed this as completed Mar 13, 2023
@abcd-ca
Copy link
Contributor

abcd-ca commented Mar 15, 2023 via email

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

No branches or pull requests

3 participants