Create-nuxt-app: Express with my nuxt app?

Created on 29 Jun 2020  Â·  19Comments  Â·  Source: nuxt/create-nuxt-app

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?

Most helpful comment

@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.

All 19 comments

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?

Server templates

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]

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...

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)

Articles:

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?

@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

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

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

@JordashTalon agreed

@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.

@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

@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."

@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.

@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

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OndrejCibulka picture OndrejCibulka  Â·  6Comments

Aperrix picture Aperrix  Â·  4Comments

miteyema picture miteyema  Â·  6Comments

tabishiqbal picture tabishiqbal  Â·  5Comments

stevenho0811 picture stevenho0811  Â·  10Comments