Crates.io | actix-web-nextjs |
lib.rs | actix-web-nextjs |
version | 0.2.7 |
source | src |
created_at | 2024-08-07 06:42:24.515602 |
updated_at | 2024-08-12 13:17:50.447662 |
description | Actix Web service for hosting statically exported Next.js apps |
homepage | https://github.com/ccmvn/actix-web-nextjs |
repository | https://github.com/ccmvn/actix-web-nextjs |
max_upload_size | |
id | 1328135 |
size | 33,928 |
Actix Web service for hosting statically exported Next.js apps. This is a fork of the SPA feature from actix-web-lab with added support for Next.js dynamic routes.
The actix-web-nextjs
service makes it easy to serve statically exported Next.js applications. Key features include:
/pet/dog/husky
into /pet/[petType]/[breed].html
.The service searches for the _buildManifest.js
file generated by Next.js and builds a tree of routes from it. Requests like /pet/dog/husky
resolve into /pet/[petType]/[breed].html
. When a new request with a specific route is made, the service attempts to find and serve the corresponding file based on the dynamic route structure. If the file is not found, it defaults to serving the index file.
use actix_web::App;
use actix_web_nextjs::spa;
let app = App::new()
// API routes and other services
.service(
spa()
.index_file("dist/index.html")
.static_resources_mount("dist")
.static_resources_location("/")
.finish()
);
Add actix-web-nextjs
to your dependencies:
[dependencies]
actix-web-nextjs = "0.2.7"
actix-web-nextjs
exposes the following feature flags:
wildcards
: Enables support for wildcard routes (enabled by default).Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in actix-web-nextjs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.