You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _blogposts/community/2025-01-01-what-can-i-do-with-rescript.mdx
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: |
6
6
Can I use Vite, or Next.js? Is it only for React? Can I use Node or Deno?
7
7
---
8
8
9
-
You've taken a look and ReScript and you want to try it out, but how do you get started? There's the [installation](https://rescript-lang.org/docs/manual/latest/installation) page in the docs,
9
+
You've taken a look and ReScript and you want to try it out, but how do you get started? There's the [installation](/docs/manual/latest/installation) page in the docs,
10
10
which is great if you want to set up a new React app using [create-rescript-app](https://github.com/rescript-lang/create-rescript-app). There's instructions on how to add it to an existing project or set it up manually.
11
11
But that doesn't really answer the question "Can I use this with X?".
12
12
@@ -23,13 +23,13 @@ Console.log("Hello")
23
23
Just run `node index.res.js` and you'll see "Hello" logged to the console. You can import compiled ReScript into any project that could import JavaScript.
24
24
If you can use `.js` or `.mjs` files, you can use ReScript. This does mean that languages with different file formats like Vue or Svelte require you to import the compiled JavaScript instead of writing it directly in the `.vue` or `.svelte` files.
25
25
26
-
Real world projects are more than JavaScript files that you write; they use libraries and frameworks. This is where [bindings](https://rescript-lang.org/docs/manual/latest/external) come into play.
26
+
Real world projects are more than JavaScript files that you write; they use libraries and frameworks. This is where [bindings](/docs/manual/latest/external) come into play.
27
27
A binding is a way to tell ReScript the types and imports from external JavaScript. You can think of bindings in the same way that you need to create a `*.d.ts` file to add types to a JavaScript library that doesn't use TypeScript.
28
28
29
-
ReScript has great integration with [React](https://rescript-lang.org/docs/react/latest/introduction) and those bindings are kept up to date by the core team, but that doesn't mean you don't have other options!
29
+
ReScript has great integration with [React](/docs/react/latest/introduction) and those bindings are kept up to date by the core team, but that doesn't mean you don't have other options!
30
30
31
31
## Using existing bindings
32
-
While ReScript isn't as large as TypeScript it has a small but growing list of bindings you can find on NPM. The website has a [package explorer](https://rescript-lang.org/packages) you can use to find official and community maintained bindings.
32
+
While ReScript isn't as large as TypeScript it has a small but growing list of bindings you can find on NPM. The website has a [package explorer](/packages) you can use to find official and community maintained bindings.
33
33
Many major libraries have existing bindings. Here's a small set of what you can find.
@@ -59,7 +59,7 @@ You can also get help and guidance on how to write bindings for what you need. U
59
59
You don't need to write bindings for an entire library, or even for all of a functions arguments. Just write what you need as you go.
60
60
61
61
Let's take a look at the `format` function from [date-fns](https://date-fns.org/). We can see the [arguments in the docs](https://date-fns.org/v4.1.0/docs/format#arguments), and how it should be imported and used.
That's all we need to know to write bindings to use this function in ReScript.
78
-
The first thing we need to figure out is how to handle the type for what `date-fns` considers to be a `date`, which is `Date | string | number`. In ReScript things can't just be of different types like they can in JavaScript or TypeScript. There are a couple options here; you can make a function for each type such as `formatString` and `formatDate`, or you can create a [variant type](https://rescript-lang.org/docs/manual/latest/variant) to map to the possible input types.
79
-
Creating a function for each type is simpler, and it's most likely how you will use the library in your project. You probably have a standard type for Dates already. We'll also need a type for `FormatDateOptions` in case we want to pass options. We'll use [labled arguments](https://rescript-lang.org/docs/manual/latest/function#labeled-arguments) for our binding.
78
+
The first thing we need to figure out is how to handle the type for what `date-fns` considers to be a `date`, which is `Date | string | number`. In ReScript things can't just be of different types like they can in JavaScript or TypeScript. There are a couple options here; you can make a function for each type such as `formatString` and `formatDate`, or you can create a [variant type](/docs/manual/latest/variant) to map to the possible input types.
79
+
Creating a function for each type is simpler, and it's most likely how you will use the library in your project. You probably have a standard type for Dates already. We'll also need a type for `FormatDateOptions` in case we want to pass options. We'll use [labled arguments](/docs/manual/latest/function#labeled-arguments) for our binding.
80
80
```res
81
81
// DateFns.res - you might want to put this in a folder called "bindings" or "external"
82
82
type formatDateOptions // we're not even going to add anything to this yet until we need something
You can write new bindings and extend existing types as you need.
136
136
137
137
## How can I get started?
138
-
You can [follow this guide](https://rescript-lang.org/docs/manual/v11.0.0/converting-from-js) to add ReScript to an existing JavaScript project to get a feel for how the language works and interacts with JavaScript.
138
+
You can [follow this guide](/docs/manual/v11.0.0/converting-from-js) to add ReScript to an existing JavaScript project to get a feel for how the language works and interacts with JavaScript.
139
139
The forum is also a great place to ask questions! Feel free to drop by and ask how to get started with a specific framework or project that you want to work on,
140
140
and you'll probably get great advice and information from users who have already used ReScript for something similar.
0 commit comments