diff --git a/website/blog/2020-04-15-introducing-crank.md b/website/blog/2020-04-15-introducing-crank.md index 64588b258..605ad69b3 100644 --- a/website/blog/2020-04-15-introducing-crank.md +++ b/website/blog/2020-04-15-introducing-crank.md @@ -86,4 +86,4 @@ By combining these relatively old, almost boring technologies with JSX syntax, I And again, I sincerely apologize for creating yet another framework in an already crowded space, but I hope, if you’ve read this far, you understand why I did so, namely, because I thought React was dropping the ball in terms of its newest APIs, because I still wanted to use JSX, and because of the sudden realization that we could be doing so much more with the different function syntaxes available to us in JavaScript. -If any of this interests you, if you want to continue to use JSX over template languages, if you’re tired of debugging hooks, if you want to use promises in your components *today*, if you’re looking for a framework which has, arguably, the most “just JavaScript” story for reactivity, I encourage you to check out Crank. You can read [the documentation](/guides/getting-started) or check out the [TodoMVC example](https://codesandbox.io/s/crank-todomvc-k6s0x) that made me tear up a little. Crank is still in its early days, and there’s a lot of work to be done before it can be considered a full-fledged framework, but I think the ideas behind it are sound and I’ve thoroughly enjoyed designing it. I can’t wait to see what people build with Crank. +If any of this interests you, if you want to continue to use JSX over template languages, if you’re tired of debugging hooks, if you want to use promises in your components *today*, if you’re looking for a framework which has, arguably, the most “just JavaScript” story for reactivity, I encourage you to check out Crank. You can read [the documentation](/guides/learn-by-example) or check out the [TodoMVC example](https://codesandbox.io/s/crank-todomvc-k6s0x) that made me tear up a little. Crank is still in its early days, and there’s a lot of work to be done before it can be considered a full-fledged framework, but I think the ideas behind it are sound and I’ve thoroughly enjoyed designing it. I can’t wait to see what people build with Crank. diff --git a/website/guides/00-getting-started.md b/website/guides/00-getting-started.md new file mode 100644 index 000000000..a3f2a1864 --- /dev/null +++ b/website/guides/00-getting-started.md @@ -0,0 +1,152 @@ +--- +title: Installation +--- + +Crank is available on [NPM](https://npmjs.org/@bikeshaving/crank) and on the unpkg CDN, in the ESModule and CommonJS formats. + +## In the browser (no build tool) + +You can use Crank directly in your browser, without a build step, like this. + +```html + + + + +``` + +(Don't do this in production! Transpiling JSX and importing Crank in the user's browser at runtime hurts performance. It's better to transpile JSX and bundle Crank ahead of time, during a build step on your own computer. But this is an easy way to try out Crank.) + +## Use JSX with Babel and Parcel + +Crank is designed to be used with a JSX transpiler. In this example, we'll set up [Babel](https://babeljs.io/) and [Parcel](https://parceljs.org/). + +```shell +$ npm install @bikeshaving/crank +$ npm install --save-dev parcel-bundler +``` + +Create a `.babelrc` file like this: + +``` +{ + "presets": [ + "@babel/preset-react" + ] +} +``` + +Create an `index.html` file like this: + +```html + +
+ + + +``` + +Create a `src` folder containing `index.js` like this: + +```jsx +/** @jsx createElement */ +import {createElement} from "@bikeshaving/crank"; +import {renderer} from "@bikeshaving/crank/dom"; + +function Greeting({name = "World"}) { + return ( +