create-nuxt-app
create-nuxt-app copied to clipboard
Express with my 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?
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
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]
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...
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/
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
@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.
@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.
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 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..