Comments (4)
Hi @nodegin
Next.js is (from their README):
A minimalistic framework for server-rendered React applications
I don't think it fit it's purpose to add any middleware or API inside since it's made to create an isomorphic application. You API should be on another server (made with Express for example).
from next.js.
+1 on /api
from next.js.
This post seems related to my question. I don't see any way for a next app to handle POST data or ajax requests. If you have to create a separate app to act as an api just to receive writes, that makes a lot of simple projects much more time consuming.
There also doesn't seem to be any way to setup user sessions.
A method to attach an express router above the page router would probably cover all these needs. Any middleware attached to that Router would affect the request/response objects for everything else. You could then attach ajax and post routes to that router and either redirect to get routes or call .next('route')
to let the request bubble down to the page router
edit: I see now that Next isn't using express internally, so the request couldn't bubble down. However it looks like it would be fairly easy to add a step to server/index.js#run
that invokes an express app with the req/res objects and then checks if a response was sent before invoking the Next router. That doesn't address the need for sessions, however.
from next.js.
@nodegin I guess this can be closed since 2.0.0 is going to include the programmatic api.
from next.js.
Related Issues (20)
- CSS Styles from unrelated layouts are merged if they have one CSS file in common
- Route handler does not receive searchParams set by middleware without runtime edge HOT 1
- NO WARNING FOR DEFAULT EXPORT in route.ts file HOT 1
- next start does not stop next-server on kill signal
- Testing frameworks (Vitest) cannot correctly resolve React to the internal Next version, causing tests to fail HOT 1
- Testing frameworks (Vitest) cannot correctly resolve React to the internally used version, causing tests to fail
- Sitemap generation with multi languages doesn't produce the XML! HOT 1
- Edge runtime causing terser panic due to top level await
- Redirecting to same page (with different parameters) does not reload the entire page HOT 4
- Importing default from `next/document` in ESM inside a third-party package doesn't work
- Docs: 'use client' documentation is unclear about SSR HOT 1
- Cosmiconfig in Dev Mode Can't Load Configs Since 14.2
- Navigating away from parallel route with router.push() doesn't trigger catch-all HOT 1
- Parallel routing with intercepting on as modal / page have unexpected behavior HOT 3
- `unstable_cache` loads `Object` instance instead of `Map` instance from cache. HOT 3
- Standalone export Sharp executable is not present with pnpm HOT 2
- generateMetaData function HOT 1
- NextJs 14.2.2 middleware "You're importing a component that needs next/headers.... etc" HOT 1
- Multi-platform dependency cannot be correctly used with Next.js
- Unable to use `firebase-admin` on NextJS 14 (app router) middleware HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.