docs: update Fresh 2 migration info (#3161)

This commit is contained in:
Marvin Hagemeister
2025-07-31 10:46:44 +02:00
committed by GitHub
parent c08710f7dd
commit 62f8bb008e
7 changed files with 28 additions and 29 deletions
+7 -5
View File
@@ -70,14 +70,16 @@ if (Deno.args.includes("build")) {
}
```
> [info]: Fresh 1.x used Tailwind CSS v3. To keep using v3 use the
> `@fresh/plugin-tailwind-v3` instead.
### Updating `main.ts`
Similarly, configuration related to running Fresh in production can be passed to
`new App()`:
```ts
// main.ts
import { App, fsRoutes, staticFiles } from "fresh";
```ts main.ts
import { App, staticFiles } from "fresh";
export const app = new App()
// Add static file serving middleware
@@ -102,7 +104,7 @@ Both the `_500.tsx` and `_404.tsx` template have been unified into a single
Inside the `_error.tsx` template you can show different content based on errors
or status codes with the following code:
```tsx
```tsx routes/_error.tsx
export default function ErrorPage(props: PageProps) {
const error = props.error; // Contains the thrown Error or HTTPError
if (error instanceof HttpError) {
@@ -138,7 +140,7 @@ export const handler = {
};
// Render that in _app.tsx
export default function AppWrapper(ctx: FreshContext) {
export default function AppWrapper(ctx: Context) {
return (
<html lang="en">
<head>