This project is a Foreign Function Interface (FFI) for using PureScript with Next.js. It allows you to write your Next.js pages and components in PureScript while leveraging the power and simplicity of Next.js.
- Write your Next.js pages and components in PureScript
- Automatic compilation of PureScript code to JavaScript
- Support for client-side components
- Seamless integration with Next.js file-based routing
Before getting started, make sure you have the following installed:
- Bun - A fast all-in-one JavaScript runtime
- PureScript - A strongly-typed functional programming language that compiles to JavaScript
-
Clone the repository:
git clone https://github.com/your-username/next-purescript-ffi.git
-
Install the dependencies:
bun install
-
Compile the PureScript code:
bun compile
-
Start the development server:
bun dev
-
Open your browser and visit
http://localhost:3000
to see your Next.js app powered by PureScript!
To create pages in your Next.js app using PureScript, follow these steps:
-
Create a new
.purs
file in thesrc/App
directory, such asPage.purs
orLayout.purs
. -
Write your PureScript code for the page or layout component.
-
The compiler will automatically detect the PureScript files and generate the corresponding JavaScript code in the
app/
directory.
If you need to use client-side components in your PureScript code, follow these steps:
-
At the top of your
.purs
file, add the following comment:-- use client
-
Write your PureScript code for the client-side component.
-
The compiler will handle the necessary setup to enable client-side rendering for that component.
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
This project is licensed under the MIT License.