0.1.0 • Published 5 years ago

next-rust v0.1.0

Weekly downloads
5
License
-
Repository
-
Last release
5 years ago

Deploy to now

WebAssembly example

How to use

wasm-pack build
wasm-pack pack pkg
wasm-pack publish

Using create-next-app

Execute create-next-app with Yarn or npx to bootstrap the example:

npx create-next-app --example with-webassembly with-webassembly-app
# or
yarn create next-app --example with-webassembly with-webassembly-app

Download manually

Download the example:

curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-webassembly
cd with-webassembly

Install it and run:

This example uses Rust compiled to wasm, the wasm file is included in the example, but to compile your own Rust code you'll have to install Rust.

npm install
npm run dev
# or
yarn
yarn dev

To compile src/add.rs to add.wasm use npm run build-rust.

Deploy it to the cloud with now (download)

now

The idea behind the example

This example shows how to import WebAssembly files (.wasm) and use them inside of a React component that is server rendered. So the WebAssembly code is executed on the server too. In the case of this example we're showing Rust compiled to WebAssembly.

etc

www

https://medium.com/@miiny/unit-test-next-js-with-jest-and-enzyme-5b305a8e29fe

import { shallow } from 'enzyme'
import MyPage from '../components/my-page'

describe('My Page', () => {
  var wrapper

  beforeEach(async () => {
    const props = await MyPage.getInitialProps()
    wrapper = shallow(<MyPage {...props} />)
  })
})

for the fetch call in props, https://www.npmjs.com/package/jest-fetch-mock

https://qiita.com/yoshi_ksk/items/ef08c84c17f07d9da3d0

https://github.com/josephluck/next-typescript-monorepo

https://www.youtube.com/watch?v=vflleO_p6eM

check next.js apollo video tutorials

https://www.youtube.com/user/99baddawg/videos