create-nuxt-app icon indicating copy to clipboard operation
create-nuxt-app copied to clipboard

Express with my nuxt app?

Open paulgrasser opened this issue 4 years ago • 22 comments

I noticed that I cannot specify my backend framework anymore, in this case I would like to use express. Is this just not possible anymore?

paulgrasser avatar Jun 29 '20 21:06 paulgrasser

View https://github.com/nuxt/create-nuxt-app/issues/559 and https://github.com/nuxt/create-nuxt-app/pull/501

Is deprecated in version 3.0

Use nuxt-render https://nuxtjs.org/api/nuxt-render or serverMiddleware https://nuxtjs.org/api/configuration-servermiddleware

jerosoler avatar Jun 30 '20 08:06 jerosoler

View #559 and #501

Is deprecated in version 3.0

Use nuxt-render https://nuxtjs.org/api/nuxt-render or serverMiddleware https://nuxtjs.org/api/configuration-servermiddleware

Why was it deprecated?

robbylucia avatar Jul 08 '20 17:07 robbylucia

Server templates

jerosoler avatar Jul 08 '20 17:07 jerosoler

For anyone who doesn't want to drop their current workflow, you can just use the latest working version with this command: npx [email protected]

robbylucia avatar Jul 09 '20 16:07 robbylucia

More time consuming to use Nuxt....

Where can we see the discussed various reasons about why removing the server template? I could not see the necessity of it... From my perspective, it's another feature which only increasing the mental burden and nothing more. Forgive my ability to understand the new docs, so we are stuck to Connect middleware ? I could not find where to switch to koa or express middleware, anyone found it? Please give me some tip...

wizardpisces avatar Jul 10 '20 10:07 wizardpisces

Hi. I can fully understand suddenly changing workflow that some users used to would be hard.

We had to remove programmatic usage of Nuxt from CNA template because otherwise more and more users could wrongly choose this option which is not a good practice for most use cases because of several DX issues (like full server reload) and deployment (loading correct dist assets) also issues for ESM and typescript support.

This doesn't mean we deprecated programmatic usage and it was even improved recently nuxt/nuxt.js#6868 (docs) and will be better in nuxt3 for first class serverless and custom server support but it is only recommended for advanced users that can handle all edge cases thus removed from CNA template. The current alternative recommended approach is using a serverMiddleware to use express for API routes (supports HMR as well) or using separate server or serverless functions.

There are also custom backend templates: (maybe outdated)

  • Express: https://github.com/nuxt-community/express-template
  • Koa: https://github.com/nuxt-community/koa-template
  • Addonis: https://github.com/nuxt-community/adonuxt-template
  • Hapi (deprecated): https://github.com/nuxt-community/hapi-nuxt

Articles:

  • Express (@manniL is updating usage to align docs): https://blog.lichter.io/posts/nuxt-with-an-api
  • Fastify (not official): https://hire.jonasgalvez.com.br/2020/feb/22/the-ultimate-nuxt-api-setup/

pi0 avatar Jul 10 '20 10:07 pi0

I'm having a lot of trouble connecting the dots with this documentation:

https://nuxtjs.org/api/configuration-servermiddleware

I don't see how that explains that now that the express option is removed how do I use the server middleware to create an express app that runs parallel to the Nuxt app? Is there a more in-depth tutorial for that process?

JordashTalon avatar Jul 16 '20 21:07 JordashTalon

@jerosoler

I'm looking at this page as well: https://nuxtjs.org/api/nuxt-render

And i'm not sure where to put that code for the express example, what file should that code go in?

EDIT:

For anyone having a lot of trouble with this new setup like I was I found this tutorial to be super helpful: https://bithacker.dev/use-express-with-nuxt-js

JordashTalon avatar Jul 16 '20 22:07 JordashTalon

@JordashTalon

Use command with old version and compare with new version. npx [email protected]

jerosoler avatar Jul 17 '20 07:07 jerosoler

@jerosoler Ok, would be nice if they had a full example in the documentation, it's really vague

JordashTalon avatar Jul 17 '20 18:07 JordashTalon

@JordashTalon agreed

SwapnilSoni1999 avatar Jul 20 '20 07:07 SwapnilSoni1999

@pi0 Thank you so much for the detailed update. I don't want to be a nuisance, nor do I want to seem like I'm demanding anything-- just asking: Will the improvements in Nuxt3 bring back the easy "one-click-install" experience that server template users were used to? As of now I am continuing to use version 2.15.0 until further notice.

Sorry if this has been answered elsewhere.

robbylucia avatar Jul 20 '20 16:07 robbylucia

@pi0 this documentation states that you must choose a back-end in order to host in Azure: https://nuxtjs.org/faq/deployment-azure-portal/

Is that still the case? What should I be doing instead please?

Thanks

dan-hammond avatar Jul 24 '20 13:07 dan-hammond

@pi0 Thank you so much for the detailed update. I don't want to be a nuisance, nor do I want to seem like I'm demanding anything-- just asking: Will the improvements in Nuxt3 bring back the easy "one-click-install" experience that server template users were used to? As of now I am continuing to use version 2.15.0 until further notice.

Sorry if this has been answered elsewhere.

one-click-install It's what I want. If I can, it's "great again."

ideacco avatar Aug 20 '20 10:08 ideacco

@dan-hammond Docs is outdated unfortounatly. I know @f3ltron is working on an article for azure :) (spoiler)

@ideacco @robbylucia Your demand is correct. Nuxt 3 would generate a server.js by default so it is zero click ;) Meanwhile you can use express-template which is properly configuring express api as a serverMiddleware.

pi0 avatar Sep 02 '20 09:09 pi0

@dan-hammond Docs is outdated unfortounatly. I know @f3ltron is working on an article for azure :) (spoiler)

@ideacco @robbylucia Your demand is correct. Nuxt 3 would generate a server.js by default so it is zero click ;) Meanwhile you can use express-template which is properly configuring express api as a serverMiddleware.

server.js by default? That's amazing. I look forward to it

robbylucia avatar Sep 02 '20 14:09 robbylucia

It wll take a bit of time but I am working on it as much as possible. It's already working now ii have to write a good article. but soon soon :). Thank's @pi0

flozero avatar Sep 02 '20 20:09 flozero

I am having a headache trying to connect node-spdy over nuxt. I am using express to call app.use(nuxt.render).

All I get is a HTTP/1.1 connection over SSL. This is really exhausting.

StEvUgnIn avatar Oct 04 '20 12:10 StEvUgnIn

Indeed, very exhausting! I was trying to migrate a vue-express SPA to SSR to end up with MPA that uses socket.io with Google APIs, stripe and peerjs, what a headache — I am keeping an open mind about Nuxt and the team's great work.

carloslema avatar Oct 08 '20 17:10 carloslema

@dan-hammond Docs is outdated unfortounatly. I know @f3ltron is working on an article for azure :) (spoiler)

@ideacco @robbylucia Your demand is correct. Nuxt 3 would generate a server.js by default so it is zero click ;) Meanwhile you can use express-template which is properly configuring express api as a serverMiddleware.

how about koa-template, it hasn't been updated for 3 years.

bi-kai avatar Feb 12 '21 01:02 bi-kai

Man this is a stupid change. Removing a feature because you think we're too dumb to use it correctly. All it does is make using your platform more complicated, confusing and time consuming. For the life of me I cannot understand why this was possibly a good idea, and telling people to use an older version as a workaround... equally as frustrating and stupid.

JamesAlphonse avatar Mar 23 '21 22:03 JamesAlphonse

@JamesAlphonse Feel free Vue and vue-cli for more flexibility. Nuxt can be really confusing for advanced websites, especially if you don't need nuxt modules..

StEvUgnIn avatar Mar 27 '21 01:03 StEvUgnIn