Fastify plugin for Vite integration.
A small but important patch containing the following fix:
See the release notes for v6.0.0 here.
This release contains a small addition allowingdecorateReply
and decorateRequest
to be exported from route modules, for purposes of preinitialisation of properties added to either object (and avoiding changing the V8 shape of them in runtime).
export const decorateRequest = ['data']
export function preHandler (req, _, done) {
req.data = {}
done()
}
export default () => (
<>
<h1>Page</h1>
</>
)
Note that all of Fastify's route-level hooks can be already exported from route modules, as demonstrated above. This feature is provided by default in @fastify/vite
, namely, in its default definition for the createRoute()
hook.
This is the first release for an experimental HTMX renderer for @fastify/vite
, with JSX support provided via @kitajs/html.
@fastify/vite
.Documentation and benchmarks will be added soon. For now here's a rundown of its features:
*.css
, *.svg
and *.client.js
files, these are also loaded on the client.ssr-manifest.json
./views
folder, need to export path
./layouts
folder./fragments
folder.
<html>
and <body>
shells.Play with the example in starters/htmx-kitchensink
to learn more.
This is the sixth major release of @fastify/vite
.
It has important changes that required the introduction of a couple of breaking changes, thus the new major release.
Both @fastify/[email protected]
and @fastify/[email protected]
still require @fastify/vite@5
to run.
Updated versions of these packages will be released soon.
Type definitions have been comprehensively expanded, hat off to @Gehbt.
The default reply.html()
function, returned by createHtmlTemplateFunction()
, now always returns a Readable
. And any parameter passed to it can also be a Readable
. In addition, placeholders now also support the dot notation, and receive app
(the Fastify plugin scope), req
, reply
, client
and route
as part of their default context in the default createRouteHandler()
definition . For the following index.html
:
<head><!-- req.head --></head>
The following reply.html()
call should work:
import { Readable } from 'node:stream'
async function * head () {
yield '<title>Streaming title</title>'
}
req.head = Redable.from(head())
reply.html({ req })
If no createRenderFunction
function is provided, createRouteHandler()
will now by default call the route module's default
export, as follows:
createRouteHandler({ client, route }, scope, config) {
// ...
return async (req, reply) => {
const page = await route.default({ app: scope, req, reply })
return reply.html({
app: scope,
req,
reply,
route,
client,
element: page,
})
}
The plugin's config object now has two injected readonly properties:
hasRenderFunction
indicates whether or createRenderFunction
was provided.ssrManifest
contains the parsed JSON from the ssr-manifest.json
file (production only).The default call signature of reply.render()
in createRouteHandler()
changed as follows:
- const page = await reply.render(scope, req, reply)
- return reply.html(page)
+ const page = await reply.render({
+ app: scope,
+ req,
+ reply,
+ route,
+ client,
+ })
The default call signature of createRouteHandler()
and createErrorHandler()
have changed as follows:
- createRouteHandler (client, scope, config) {
+ createRouteHandler({ client, route }, scope, config) {
- createErrorHandler (client, scope, config) {
+ createErrorHandler({ client, route }, scope, config) {
In both cases, route
is a reference to the route module, and client
is a reference to the client module.
Many thanks to the contributors!
Node v20+ is now used in development.
Vitest has been replaced with Node's native test runner.
ESLint has been replaced with Biome for speed[^1].
[^1]: Biome is lacking a formatting option that makes it not fully StandardJS-compliant, but it's an acceptable compromise since it was possible to remove several ESLint plugins from the dependencies and still have superior performance.
This is a new minor release for @fastiffy/react containing an important change:
Which makes route modules able to receive POST
, PUT
and DELETE
requests.
This is a new minor release for @fastiffy/vue containing an important change:
Which makes route modules able to receive POST
, PUT
and DELETE
requests.
This is a patch for the v5 release line including:
This is a patch for the v5 release line including:
This is a critical patch for the v5 release line.
It includes a missing file from the bundle, the @fastify/vite/utils
export.
This bug was only identified testing the starter templates outside the pnpm workspace environment.