2017-08-27 22:13:35 +02:00
# Example app using ReasonML & ReasonReact components
2020-01-16 23:23:56 +01:00
This example features:
- An app that mixes together JavaScript and ReasonML components and functions
- An app with two pages which has a common Counter component
- That Counter component maintain the counter inside its module. This is used
primarily to illustrate that modules get initialized once and their state
variables persist in runtime
2019-11-27 17:40:58 +01:00
## Deploy your own
2020-04-21 11:47:12 +02:00
Deploy the example using [Vercel ](https://vercel.com ):
2019-11-27 17:40:58 +01:00
2020-05-27 20:11:39 +02:00
[![Deploy with Vercel ](https://vercel.com/button )](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-reasonml)
2019-11-27 17:40:58 +01:00
2017-08-27 22:13:35 +02:00
## How to use
2017-12-03 05:30:17 +01:00
### Using `create-next-app`
2020-05-27 23:51:11 +02:00
Execute [`create-next-app` ](https://github.com/vercel/next.js/tree/canary/packages/create-next-app ) with [npm ](https://docs.npmjs.com/cli/init ) or [Yarn ](https://yarnpkg.com/lang/en/docs/cli/create/ ) to bootstrap the example:
2017-12-03 05:30:17 +01:00
2018-03-14 09:09:46 +01:00
```bash
2020-01-16 23:23:56 +01:00
npm init next-app --example with-reasonml with-reasonml-app
2018-03-14 09:09:46 +01:00
# or
yarn create next-app --example with-reasonml with-reasonml-app
2017-12-03 05:30:17 +01:00
```
### Download manually
2018-07-11 23:56:15 +02:00
Download the example:
2017-08-27 22:13:35 +02:00
```bash
2020-05-27 20:11:39 +02:00
curl https://codeload.github.com/vercel/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-reasonml
2017-08-27 22:13:35 +02:00
cd with-reasonml
```
Install it and run:
```bash
npm install
npm run dev
2018-04-03 14:19:05 +02:00
# or
yarn
yarn dev
```
Build and run:
```bash
npm run build
npm run start
# or
yarn build
yarn start
2017-08-27 22:13:35 +02:00
```
2020-04-21 11:47:12 +02:00
Deploy it to the cloud with [Vercel ](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example ) ([Documentation](https://nextjs.org/docs/deployment)).
2018-04-03 14:19:05 +02:00
2017-09-30 22:02:45 +02:00
### Recommendation:
Run BuckleScript build system `bsb -w` and `next -w` separately. For the sake
of simple convention, `npm run dev` run both `bsb` and `next` concurrently.
However, this doesn't offer the full [colorful and very, very, veeeery nice
error
2018-02-06 15:22:32 +01:00
output](https://reasonml.github.io/blog/2017/08/25/way-nicer-error-messages.html)
2017-09-30 22:02:45 +02:00
experience that ReasonML can offer, don't miss it!
2017-08-27 22:13:35 +02:00
2019-04-19 22:28:28 +02:00
There are 2 convenience scripts to facilitate running these separate processes:
1. `npm run dev:reason` - This script will start the ReasonML toolchain in
watch mode to re-compile whenever you make changes.
2. `npm run dev:next` - This script will start the next.js development server
so that you will be able to access your site at the location output by the
script. This will also hot reload as you make changes.
You should start the scripts in the presented order.