not really known
Go to file
2023-01-16 09:42:37 +00:00
src/Next add query method 2023-01-16 09:42:37 +00:00
test Initial commit 2022-08-28 21:01:34 +01:00
.gitignore Initial commit 2022-08-28 21:01:34 +01:00
package.json Initial commit 2022-08-28 21:01:34 +01:00
packages.dhall Add Router.replace 2023-01-09 09:20:13 +00:00
README.md Add credits 2023-01-13 19:23:01 +00:00
spago.dhall Add slime additions 2023-01-16 09:42:37 +00:00

purescript-nextjs

Purescript FFI bindings to Next.js.

In order to bootstrap a Next.js project with Purescript you can use our 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. 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.

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 router

        dispatchRoute = 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, which is licensed under MIT.