Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/purescript-react/purescript-nextjs
https://github.com/purescript-react/purescript-nextjs
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/purescript-react/purescript-nextjs
- Owner: purescript-react
- License: mit
- Created: 2022-08-28T20:00:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-23T11:08:26.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T07:24:07.590Z (8 months ago)
- Language: PureScript
- Size: 86.9 KB
- Stars: 10
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-purescript - nextjs - Use the #1 react framework in Purescript. (UI / React)
README
# purescript-nextjs
Purescript FFI bindings to [Next.js](https://nextjs.org).
In order to bootstrap a Next.js project with Purescript you can use our [`purescript-nextjs-template`](https://github.com/rowtype-yoga/purescript-nextjs-template). You can find the information on how to get started in that repo.
## Usage
Once you have set up a Next.js project, you can use the FFI bindings here. This library provides bindings for many of the features described in the [Next.js documentation](https://nextjs.org/docs). We don't have FFI for everything yet, if you are missing something feel free to create an issue or even better: create a PR!
### Router
Here is an example how to use the router.```purescript
import React.Basic.DOM.Simplified.Generated as R
import React.Basic.Hooks as React
import Next.Router as NextRouter...
React.component "MyComponent" \props -> React.do
router <- NextRouter.useRouter
let
q :: { myQueryParam :: String }
q = query routerdispatchRoute = Router.push Router
pure $ R.button { onClick: handler_ $ dispatchRoute "/about" } "Click me"
```## Credits
This lib has been heavily inspired by and initially extracted from [`next-purescript-example`](https://github.com/jonasbuntinx/next-purescript-example), which is licensed under [MIT](https://github.com/jonasbuntinx/next-purescript-example/blob/master/LICENSE).