Repository navigation
fix Paraglide Start scaffold integration #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tannerlinsley
merged 4 commits into
TanStack:main
from
samuelstroschein:codex/fix-paraglide-start-integration
Nov 12, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4b15b47
fix Paraglide Start scaffold integration
samuelstroschein 6cc7bba
Merge main and compose Paraglide server entry points
tannerlinsley ec5cf15
fix(create): remove obsolete Paraglide demo asset
tannerlinsley 028d720
Merge main and compose Paraglide with Workers Sentry
tannerlinsley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@tanstack/create': patch | ||
| '@tanstack/cli': patch | ||
| --- | ||
|
|
||
| Configure the Paraglide add-on with TanStack Router URL rewrites and request-scoped server middleware. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/create/src/frameworks/react/add-ons/paraglide/assets/src/server.ts.ejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <% if (addOnEnabled.vercel && addOnEnabled.sentry) { ignoreFile(); return; } -%> | ||
| import handler, { createServerEntry } from '@tanstack/react-start/server-entry' | ||
| import { paraglideMiddleware } from './paraglide/server.js' | ||
|
|
||
| export default createServerEntry({ | ||
| fetch(request, options) { | ||
| return paraglideMiddleware(request, () => handler.fetch(request, options)) | ||
| }, | ||
| }) | ||
2 changes: 1 addition & 1 deletion
2
packages/create/src/frameworks/react/hosts/cloudflare/assets/src/worker.ts.ejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import { | ||
| finalizeAddOns, | ||
| populateAddOnOptionsDefaults, | ||
| } from '../src/add-ons.js' | ||
| import { createApp } from '../src/create-app.js' | ||
| import { createMemoryEnvironment } from '../src/environment.js' | ||
| import { createFrameworkDefinition } from '../src/frameworks/react/index.js' | ||
|
|
||
| import type { Framework, FrameworkDefinition, Options } from '../src/types.js' | ||
|
|
||
| function frameworkFromDefinition(definition: FrameworkDefinition): Framework { | ||
| const { addOns, base, ...framework } = definition | ||
|
|
||
| return { | ||
| ...framework, | ||
| getFiles: () => Promise.resolve(Object.keys(base)), | ||
| getFileContents: (path: string) => Promise.resolve(base[path]), | ||
| getDeletedFiles: () => Promise.resolve([]), | ||
| getAddOns: () => addOns, | ||
| } | ||
| } | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllGlobals() | ||
| }) | ||
|
|
||
| describe('Paraglide add-on', () => { | ||
| it('configures localized routing and request-scoped SSR', async () => { | ||
| vi.stubGlobal( | ||
| 'fetch', | ||
| vi.fn( | ||
| async () => | ||
| new Response(JSON.stringify({ version: '1.0.0' }), { status: 200 }), | ||
| ), | ||
| ) | ||
|
|
||
| const framework = frameworkFromDefinition(createFrameworkDefinition()) | ||
| const chosenAddOns = await finalizeAddOns(framework, 'file-router', [ | ||
| 'paraglide', | ||
| ]) | ||
| const options = { | ||
| projectName: 'paraglide-app', | ||
| targetDir: '/paraglide-app', | ||
| framework, | ||
| mode: 'file-router', | ||
| typescript: true, | ||
| tailwind: true, | ||
| packageManager: 'pnpm', | ||
| git: false, | ||
| install: false, | ||
| intent: false, | ||
| includeExamples: true, | ||
| chosenAddOns, | ||
| addOnOptions: populateAddOnOptionsDefaults(chosenAddOns), | ||
| } as Options | ||
| const { environment, output } = createMemoryEnvironment() | ||
|
|
||
| await createApp(environment, options) | ||
|
|
||
| const router = output.files['/paraglide-app/src/router.tsx'] | ||
| expect(router).toContain( | ||
| "import { deLocalizeUrl, localizeUrl } from './paraglide/runtime'", | ||
| ) | ||
| expect(router).toContain('input: ({ url }) => deLocalizeUrl(url)') | ||
| expect(router).toContain('output: ({ url }) => localizeUrl(url)') | ||
|
|
||
| const server = output.files['/paraglide-app/src/server.ts'] | ||
| expect(server).toContain( | ||
| "import { paraglideMiddleware } from './paraglide/server.js'", | ||
| ) | ||
| expect(server).toContain("from '@tanstack/react-start/server-entry'") | ||
| expect(server).toContain( | ||
| 'return paraglideMiddleware(request, () => handler.fetch(request, options))', | ||
| ) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
rg -n "strategy|paraglideVitePlugin|cookie" packages/create/src/frameworks/react/add-ons/paraglide cat packages/create/src/frameworks/react/add-ons/paraglide/assets/src/server.ts.ejs ls packages/create/src/frameworks/react/add-ons/paraglideRepository: TanStack/cli
Length of output: 577
Script executed:
Repository: TanStack/cli
Length of output: 41645
Script executed:
Repository: TanStack/cli
Length of output: 41306
Script executed:
Repository: TanStack/cli
Length of output: 39589
Web query:
Paraglide JS 2.13.1 TanStack Start official example server functions strategy url baseLocale cookie preferredLanguage locale _serverFnResult:
Web query:
site:raw.githubusercontent.com/TanStack/router/main/examples/react/start-i18n-paraglide vite.config.ts paraglideVitePlugin strategyResult:
Web query:
TanStack Start server functions _serverFn endpoint URL official documentationResult:
Preserve the page locale for server-function requests.
TanStack Start sends server-function calls to
/_serverFn/.... The middleware resolves that request separately from the document request. With onlyurlandbaseLocale, a call from a German page can fall back toen, so translated server-function results can differ from the page locale. Add the server-visible cookie and preferred-language fallbacks used by the official TanStack Start Paraglide example.Suggested fix
plugins: [<% if (showDevtools) { %>devtools(), <% } %><% if (addOnEnabled.paraglide) { %>paraglideVitePlugin({ project: "./project.inlang", outdir: "./src/paraglide", - strategy: ['url', "baseLocale"], + cookieName: 'PARAGLIDE_LOCALE', + strategy: ['url', 'cookie', 'preferredLanguage', 'baseLocale'], }),<% } %>]