Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omarkhatibco/adonis-nextjs
A provider to initialize nextjs app with adonis.
https://github.com/omarkhatibco/adonis-nextjs
adonis nextjs react
Last synced: about 2 months ago
JSON representation
A provider to initialize nextjs app with adonis.
- Host: GitHub
- URL: https://github.com/omarkhatibco/adonis-nextjs
- Owner: omarkhatibco
- License: mit
- Created: 2018-04-05T20:55:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-09T08:04:54.000Z (over 4 years ago)
- Last Synced: 2024-07-24T22:11:35.761Z (about 2 months ago)
- Topics: adonis, nextjs, react
- Language: JavaScript
- Size: 18.6 KB
- Stars: 34
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-adonisjs-packages - Adonis Nextjs - A provider to initialize nextjs app with adonis. (Third-party Service Integration)
README
# Adonis Nextjs 🚀
> A provider to initialize nextjs app with adonis.
[![npm](https://img.shields.io/npm/v/adonis-nextjs.svg)](https://www.npmjs.com/package/adonis-nextjs)
## Installation
You can install the package from npm.
this provider assume you have nextjs, React & React Dom
```bash
adonis install adonis-nextjs
```## Configure
### Register provider
The provider must be registered as a `provider`.
```javascript
const providers = [...,'adonis-nextjs/providers/NextProvider'];
```## Register your routes
```javascript
const Route = use('Route');
const Next = use('Adonis/Addons/Next');
const handler = Next.getRequestHandler();// API Endpoint for your database
Route.get('/api', ({ request }) => {
return { greeting: "I'm Api Endpoint" };
});// * Next Routes
Route.get('/b', ({ request, response }) => {
const query = request.get();
return Next.render(request.request, response.response, '/b', query);
});Route.get('/post/:id', ({ request, response, params }) =>
Next.render(request.request, response.response, '/b', {
id: params.id
})
);Route.get(
'*',
({ request, response }) =>
new Promise((resolve, reject) => {
handler(request.request, response.response, promise => {
promise.then(resolve).catch(reject);
});
})
);
```## Adding next.js folder
The next project directory is `next` by default, but you can change it using environment variables `NEXT_FOLDER`.
## Register next.js Commands
```json
{
"scripts": {
"dev": "node server.js",
"build": "next build ./next",
"export": "next export ./next",
"start": "NODE_ENV=production node server.js"
}
}
```## Release History
Checkout [CHANGELOG.md](https://github.com/omarkhatibco/adonis-nextjs/blob/master/CHANGELOG.md) file for release history.
## Meta
[@AdonisJs](http://adonisjs.com/)
[@nextjs](https://github.com/zeit/next.js/)
Checkout [LICENSE](https://github.com/omarkhatibco/adonis-nextjs/blob/master/LICENSE) for license information.