score:0
Apparently there is no alternative to nodejs server, which is not an option for me currently, so I unfortunately had to abandon next.js and create a CRA app and used as much from the next.js as I could.
score:2
Actually the acepted answer is completly wrong, when you do yarn build
and in your package.json is set like "build": "next build && next export",
you will get an out folder which all the items in there are used to build without node.js server
Now since you are using laravel, and you use the out folder you will only load half of the page because the routes are not set properly. for that to work you need to edit your next.config.js edit it to
module.exports = {
distDir: '/resources/views',
assetPrefix: '/resources/views',
}
These will set the root directory to the root one in Laravel. now this will work for SPA (single page application) only for the dynamic routes you need to match with a view file for each one that you have in your out folder
For each route that you have you need to create a new "get" route in laravel
Route::get('/', function () {
return require resource_path('views/index.html');
});
Route::get('/contacts', function () {
return require resource_path('views/contacts.html');
});
Route::get('/post/{slug}', function () {
return require resource_path('views/post/[slug].html');
});
Notice that you can pass a wildcard for dynamic routes and they are all gonna work. once you do that and you deploy route out folder inside /resources/views in Laravel it's going to work
Source: stackoverflow.com
Related Query
- how to deploy next js app without vercel to custom server using ftp server like filezilla
- How to deploy a React App on Apache web server
- How to deploy a react app to mutiple environments without multiple builds?
- How can I start my node server and react app at the same time?
- How to deploy React App on production with Server Side Rendering
- How to send file from React/Next.js client UI to Node server and next to Flask service
- How to deploy Next.js app without Node.js server?
- Not Sure How to Start and Deploy ReactJS App on Production Server with ExpressJS
- How to deploy react app in ubuntu server with bitbucket pipeline
- How to deploy a react app that does not have index.html on an apache server for production
- How to deploy and host react app on Apache server
- How to deploy react, next js + express js app to netlify?
- How can I make my front end app access my node server apis
- Cannot deploy React app at Node JS server
- How do I deploy ReactJs + Node app onto remote server?
- How to add CSS server side render for React Next app with Material-ui
- How to deploy node js app with react to heroku
- How do I run a React App without JS Node just vanilla VSC for a class
- How to start node server when React app starts in production
- React tutorial - how do I start the node server for a reactJs application?
- How to fetch data only once in a Next.js app and make it accesible to all the app, both in server and client
- How to deploy a react app on cPanel?
- ReactJS: How to deploy on local server
- How to set App bar component without iconElementLeft?
- How to use jinja2 server side rendering alongside react without violating inline-script CSP
- how to share environment variables between react app and express js server hosting it as static site
- how to deploy reactJS application on Tomcat Server
- How do I configure my Nginx server to work with a React app in a subfolder?
- How to create a React App without Create-react-app
- How to server side redirect to other page without reloading the page and still keeping the url in Nextjs app?
More Query from same tag
- How to create this react modal the right way?
- MUI Grid 2 Columns - Custom Heights
- How to get an image's width and height after scaling & rendering the react component
- React/Firebase -> DocumentReference.set() called with invalid data. Unsupported field value: undefined
- Infinite Loop With Higher Order React Redux Component
- Prevent clicking on element
- Canvas drawImage layering
- How to set background image for entire screen in app js file in react js?
- "React has detected a change in the order of Hooks" but Hooks seem to be invoked in order
- How does JS understand props parameter as object in any function (react.js)?
- How do I use the window object in ReactJS?
- React nested route fails to load
- Use Microsoft Graph Toolkit with msal-browser
- Child combinator applied to parent in production
- How to get props from parent in React Styled Components
- ReactJS - Return a component from innerHtml function
- Compare previous state to new one in React Redux
- Why doesn't the loader show on the second test when I run the same test twice in jest, using react testing library, react.lazy, and suspense?
- Providing data through a HOC but when calling component Property '' is missing in type '{}' but required in type '' error appears
- How to turn React Component able to receive variables
- Creating react library with rollup.js i get error null (reading 'useState')
- Scrolling to top on page load
- validate confirmation password in redux form
- How can I provide a SSL certificate with create-react-app?
- How to render programmatically created table in React?
- Why do I receive an error stating onAuth is not a Function?
- ReactJS - onClick doesn't call the fucntion inside map() function
- How do I make my React state update immediately?
- In react router when routing to another page it starts from the part where i left the previous page?
- Pass down props as a parameter to another HoC within compose