Skip to content

Next.js template: Next.js 15 + fix static export #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-rescript-app",
"version": "1.9.0-beta.1",
"version": "1.9.0-beta.2",
"description": "Quickly create new ReScript apps from project templates.",
"main": "out/create-rescript-app.mjs",
"scripts": {
2 changes: 1 addition & 1 deletion src/Templates.res
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ let templates = [
{
name: "rescript-template-nextjs",
displayName: "Next.js",
shortDescription: "Next.js 14 and Tailwind CSS",
shortDescription: "Next.js 15 with static export and Tailwind 3",
},
{
name: basicTemplateName,
5 changes: 3 additions & 2 deletions templates/rescript-template-nextjs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ const transpileModules = ["rescript"].concat(rescript["bs-dependencies"]);

const config = {
pageExtensions: ["jsx", "js"],
output: "export",
env: {
ENV: process.env.NODE_ENV,
},
@@ -32,8 +33,8 @@ const config = {
},
});

return config
}
return config;
},
};

export default {
1,214 changes: 924 additions & 290 deletions templates/rescript-template-nextjs/package-lock.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions templates/rescript-template-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -4,19 +4,17 @@
"author": "Patrick Ecker <ryyppy@users.noreply.github.com>",
"license": "Apache-2.0",
"dependencies": {
"@rescript/react": "^0.12.1",
"next": "^14.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@rescript/react": "^0.13.0",
"next": "^15.1.6",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"repository": "https://github.com/rescript-lang/create-rescript-app",
"scripts": {
"dev": "next",
"debug": "NODE_OPTIONS='--inspect' next",
"build": "rescript && next build",
"now-build": "rescript && next build",
"export": "next export",
"start": "next start -p $PORT",
"start": "npx serve out",
"res:build": "rescript",
"res:clean": "rescript clean",
"res:dev": "rescript -w"
4 changes: 2 additions & 2 deletions templates/rescript-template-nextjs/pages/examples.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ExamplesRes from "src/Examples.res.mjs";

// This can be re-exported as is (no Fast-Refresh issues)
export { getServerSideProps } from "src/Examples.res.mjs";
export { getStaticProps } from "src/Examples.res.mjs";

// Note:
// We need to wrap the make call with
@@ -11,5 +11,5 @@ export { getServerSideProps } from "src/Examples.res.mjs";
// If you don't do this, your Fast-Refresh will
// not work!
export default function Examples(props) {
return <ExamplesRes {...props}/>;
return <ExamplesRes {...props} />;
}
6 changes: 3 additions & 3 deletions templates/rescript-template-nextjs/src/Examples.res
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ let default = (props: props) =>
<a href=props.href target="_blank"> {React.string("`src/Examples.res`")} </a>
</div>

let getServerSideProps = _ctx => {
let getStaticProps = _ctx => {
let props = {
msg: "This page was rendered with getServerSideProps. You can find the source code here: ",
href: "https://github.com/ryyppy/nextjs-default/tree/master/src/Examples.res",
msg: "This page was rendered with getStaticProps. You can find the source code here: ",
href: "https://github.com/rescript-lang/create-rescript-app/blob/master/templates/rescript-template-nextjs/src/Examples.res",
}
Promise.resolve({"props": props})
}
2 changes: 1 addition & 1 deletion templates/rescript-template-nextjs/src/Examples.resi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
type props
let default: props => React.element
let getServerSideProps: Next.GetServerSideProps.t<props, {.}, _>
let getStaticProps: Next.GetStaticProps.t<props, {.}, _>
13 changes: 6 additions & 7 deletions templates/rescript-template-nextjs/src/Index.res
Original file line number Diff line number Diff line change
@@ -7,13 +7,12 @@ let default = () =>
<div>
<h1 className="text-3xl font-semibold"> {"What is this about?"->React.string} </h1>
<P>
{React.string(` This is a simple template for a Next
project using ReScript & TailwindCSS.`)}
{React.string(
"This is a simple template for a Next.js 15 project with static export using ReScript & TailwindCSS 3.",
)}
</P>
<h2 className="text-2xl font-semibold mt-5"> {React.string("Quick Start")} </h2>
<pre>
{React.string(`git clone https://github.com/rescript-nextjs-template.git my-project
cd my-project
rm -rf .git`)} //github.com/ryyppy/nextjs-default.git my-project
</pre>
{React.string("Run ")}
<span className="font-mono"> {React.string(`npm create rescript-app@latest`)} </span>
{React.string(" and select Next.js template.")}
</div>
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ module Navigation = {
<a
className="px-3 font-bold"
target="_blank"
href="https://github.com/ryyppy/nextjs-default">
href="https://github.com/rescript-lang/create-rescript-app/tree/master/templates/rescript-template-nextjs">
{React.string("Github")}
</a>
</div>