
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@dblechoc/nextdotbs
Advanced tools
Type definitions for Next.js.
State:
Have a reason project already set up
Install:
npm install --save next@9 nextdotbs
(Notice how you installed both next and nextdotbs!)
Add "nextdotbs" to your "bs-dependencies" in your "bsconfig.json"
mkdir pages
Make a file: src/pages/WelcomePage.re
that defines a React component named default.
open React;
open Next;
[@react.component]
let default = () => {
<div>
<Head>
<title> "Welcome"->string </title>
</Head>
"Welcome to Next"->string
</div>;
};
cd pages && ln -s ../src/pages/WelcomePage.bs.js welcome.js
The symlinking allows us to still use the .bs.js postfix for Reason files, and also allows us to use dynamic routing and name files with square brackets inside of the pages
directory without upsetting bsb
.
Next performs data fetching for page components by looking for a static function on the component class called getInitialProps
. This isn't a pattern that ReasonReact likes, so instead, these wrappings expose a function called assignPropsFetcher
that you pass your default
value (from creating the React component) to:
open React;
open Next;
[@react.component]
let default = (~message: string) => {
<div>
<Head>
<title> "Welcome"->string </title>
</Head>
"Welcome to Next"->string
</div>;
};
// Notice how I match the props for the component above!
type props = {message: option(Post.t)};
let fetcher: propsFetcher(props) =
({req, query}) => {
// ... do some async stuff we don't show here and get a value called "message" in scope. 🧙♂️
{message: message}->Js.Promise.resolve;
};
default->assignPropsFetcher(fetcher);
That's most of it! So to re-cap, you can use it just like Next.js except:
pages
folder.assignPropsFetcher
instead of getInitialProps
.req
param that gets passed into the props fetcher will be None
on the client, but will be an object with a headers
field on the server. If you're making a request from your own server to your own API to populate data, you can get the host
and use it as the host for your HTTP request.Other things to note:
Head
React component is available for inserting tags into the head of the document.Link
React component is availalbe for slick in-app navigation.You may want to run Next alongside your own API, and you may be using Serbet for that. Here's how they can work together:
open Async;
let nextServer =
NextServer.make({
dev:
!
Node.Process.process##env
->Js.Dict.get("NODE_ENV")
->Belt.Option.map(a => a == "production")
->Belt.Option.getWithDefault(false),
});
{
let%Async _ = nextServer->NextJSServer.prepare;
let app =
Serbet.application([
// your API routes here
]);
app.router->Express.Router.use(nextServer->NextServer.getRequestHandler);
async();
};
FAQs
Type definitions for Next.js.
We found that @dblechoc/nextdotbs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.